@@ -64,7 +64,7 @@ sf plugins
64
64
65
65
## ` sf api request graphql `
66
66
67
- Execute GraphQL statements
67
+ Execute a GraphQL statement.
68
68
69
69
```
70
70
USAGE
@@ -77,48 +77,47 @@ FLAGS
77
77
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the
78
78
`target-org` configuration variable is already set.
79
79
--api-version=<value> Override the api version used for api requests made by this command
80
- --body=file (required) File or content with GraphQL statement. Specify "-" to read from
81
- standard input.
80
+ --body=file (required) File or content with the GraphQL statement. Specify "-" to read
81
+ from standard input.
82
82
83
83
GLOBAL FLAGS
84
84
--flags-dir=<value> Import flag values from a directory.
85
85
--json Format output as json.
86
86
87
87
DESCRIPTION
88
- Execute GraphQL statements
88
+ Execute a GraphQL statement.
89
89
90
- Run any valid GraphQL statement via the /graphql
91
- [API](https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html)
90
+ Specify the GraphQL statement with the "--body" flag, either directly at the command line or with a file that contains
91
+ the statement. You can query Salesforce records using a "query" statement or use mutations to modify Salesforce
92
+ records.
93
+
94
+ This command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of
95
+ queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html.
92
96
93
97
EXAMPLES
94
- - Runs the graphql query directly via the command line
95
- sf api request graphql --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } } } } } } }"
96
- - Runs a mutation to create an Account, with an `example.txt` file, containing
97
- mutation AccountExample{
98
- uiapi {
99
- AccountCreate(input: {
100
- Account: {
101
- Name: "Trailblazer Express"
102
- }
103
- }) {
104
- Record {
105
- Id
106
- Name {
107
- value
108
- }
109
- }
110
- }
111
- }
112
- }
113
- $ sf api request graphql --body example.txt
114
- will create a new account returning specified fields (Id, Name)
98
+ Execute a GraphQL query on the Account object by specifying the query directly to the "--body" flag; the command
99
+ uses your default org:
100
+
101
+ $ sf api request graphql --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } \
102
+ } } } } } }"
103
+
104
+ Read the GraphQL statement from a file called "example.txt" and execute it on an org with alias "my-org":
105
+
106
+ $ sf api request graphql --body example.txt --target-org my-org
107
+
108
+ Pipe the GraphQL statement that you want to execute from standard input to the command:
109
+ $ echo graphql | sf api request graphql --body -
110
+
111
+ Write the output of the command to a file called "output.txt" and include the HTTP response status and headers:
112
+
113
+ $ sf api request graphql --body example.txt --stream-to-file output.txt --include
115
114
```
116
115
117
- _ See code: [ src/commands/api/request/graphql.ts] ( https://github.com/salesforcecli/plugin-api/blob/1.2.1 /src/commands/api/request/graphql.ts ) _
116
+ _ See code: [ src/commands/api/request/graphql.ts] ( https://github.com/salesforcecli/plugin-api/blob/1.2.2 /src/commands/api/request/graphql.ts ) _
118
117
119
118
## ` sf api request rest ENDPOINT `
120
119
121
- Make an authenticated HTTP request to Salesforce REST API and print the response .
120
+ Make an authenticated HTTP request using the Salesforce REST API.
122
121
123
122
```
124
123
USAGE
@@ -137,32 +136,51 @@ FLAGS
137
136
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the
138
137
`target-org` configuration variable is already set.
139
138
--api-version=<value> Override the api version used for api requests made by this command
140
- --body=file File to use as the body for the request. Specify "-" to read from standard
141
- input; specify "" for an empty body.
139
+ --body=file File or content for the body of the HTTP request. Specify "-" to read from
140
+ standard input or "" for an empty body.
142
141
143
142
GLOBAL FLAGS
144
143
--flags-dir=<value> Import flag values from a directory.
145
144
145
+ DESCRIPTION
146
+ Make an authenticated HTTP request using the Salesforce REST API.
147
+
148
+ When sending the HTTP request with the "--body" flag, you can specify the request directly at the command line or with
149
+ a file that contains the request.
150
+
151
+ For a full list of supported REST endpoints and resources, see
152
+ https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm.
153
+
146
154
EXAMPLES
147
- - List information about limits in the org with alias "my-org":
148
- sf api request rest 'limits' --target-org my-org
149
- - List all endpoints
150
- sf api request rest '/'
151
- - Get the response in XML format by specifying the "Accept" HTTP header:
152
- sf api request rest 'limits' --target-org my-org --header 'Accept: application/xml'
153
- - POST to create an Account object
154
- sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
155
- - or with a file 'info.json' containing
156
- {
157
- "Name": "Demo",
158
- "ShippingCity": "Boise"
159
- }
160
- $ sf api request rest 'sobjects/account' --body info.json --method POST
161
- - Update object
162
- sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
155
+ List information about limits in the org with alias "my-org":
156
+
157
+ $ sf api request rest 'limits' --target-org my-org
158
+
159
+ List all endpoints in your default org; write the output to a file called "output.txt" and include the HTTP response
160
+ status and headers:
161
+
162
+ $ sf api request rest '/' --stream-to-file output.txt --include
163
+
164
+ Get the response in XML format by specifying the "Accept" HTTP header:
165
+
166
+ $ sf api request rest 'limits' --header 'Accept: application/xml'
167
+
168
+ Create an account record using the POST method; specify the request details directly in the "--body" flag:
169
+
170
+ $ sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \
171
+ \"Boise\"}" --method POST
172
+
173
+ Create an account record using the information in a file called "info.json":
174
+
175
+ $ sf api request rest 'sobjects/account' --body info.json --method POST
176
+
177
+ Update an account record using the PATCH method:
178
+
179
+ $ sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method \
180
+ PATCH
163
181
```
164
182
165
- _ See code: [ src/commands/api/request/rest.ts] ( https://github.com/salesforcecli/plugin-api/blob/1.2.1 /src/commands/api/request/rest.ts ) _
183
+ _ See code: [ src/commands/api/request/rest.ts] ( https://github.com/salesforcecli/plugin-api/blob/1.2.2 /src/commands/api/request/rest.ts ) _
166
184
167
185
<!-- commandsstop -->
168
186
0 commit comments