Skip to content

Commit

Permalink
chore: add exmaple, empty body message
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Aug 20, 2024
1 parent bee7ae1 commit cc7bc9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions messages/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ Make an authenticated HTTP request to Salesforce REST API and print the response

- List information about limits in the org with alias "my-org":

<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org
<%= config.bin %> <%= command.id %> 'limits' --target-org my-org

- List all endpoints

<%= config.bin %> <%= command.id %> '/'

- Get the response in XML format by specifying the "Accept" HTTP header:

<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org --header 'Accept: application/xml'
<%= config.bin %> <%= command.id %> 'limits' --target-org my-org --header 'Accept: application/xml'

- POST to create an Account object

<%= config.bin %> <%= command.id %> '/services/data/v46.0/sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
<%= config.bin %> <%= command.id %> 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST

- or with a file 'info.json' containing

Expand All @@ -25,11 +29,11 @@ Make an authenticated HTTP request to Salesforce REST API and print the response
}
```

<%= config.bin %> <%= command.id %> '/services/data/v46.0/sobjects/account' --body info.json --method POST
<%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST

- Update object

<%= config.bin %> <%= command.id %> '/services/data/v46.0/sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
<%= config.bin %> <%= command.id %> 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH

# flags.include.summary

Expand Down
2 changes: 1 addition & 1 deletion src/commands/api/request/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Rest extends SfCommand<void> {
this.styledJSON(JSON.parse(res.body) as AnyJson);
} catch (err) {
// If response body isn't JSON, just print it to stdout.
this.log(res.body);
this.log(res.body === '' ? `Server responded with an empty body, status code ${res.statusCode}` : res.body);
}

if (res.statusCode >= 400) {
Expand Down

0 comments on commit cc7bc9d

Please sign in to comment.