Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Create a Query Job
Syntax
URI: /services/data/vXX.X/jobs/query
Available since release:
This resource is available in API version 47.0 and later.
Format: application/json
HTTP method: POST
Authentication: Authorization:Bearer token
Headers: Optionally, use the Sforce-Call-Options header to specify a default namespace.
Request body
The request body specifies the query to be performed.
1{
2 "operation": "query",
3 "query": "SELECT Id FROM Account"
4}You can also specify some optional parameters. For example:
1{
2 "operation" : "query",
3 "query" : "SELECT Id FROM Account",
4 "contentType" : "CSV",
5 "columnDelimiter" : "CARET",
6 "lineEnding" : "CRLF"
7}Request parameters:
| Parameter | Description | Required or Optional |
|---|---|---|
| operation | The type of query. Possible values are:
|
Required |
| query | The query to be performed. | Required |
| contentType | The format to be used for the results. Currently the only supported value is CSV (comma-separated variables). Defaults to CSV. The actual separator can be a character other than a comma. The columnDelimiter parameter specifies what character to use. | Optional |
| columnDelimiter | The column delimiter used for
CSV job data. The default value is COMMA. Possible values are:
|
Optional |
| lineEnding | The line ending used for CSV job
data, marking the end of a data row. The default is
LF. Possible
values are:
|
Optional |
Response Body
1{
2 "id" : "750R0000000zlh9IAA",
3 "operation" : "query",
4 "object" : "Account",
5 "createdById" : "005R0000000GiwjIAC",
6 "createdDate" : "2018-12-10T17:50:19.000+0000",
7 "systemModstamp" : "2018-12-10T17:50:19.000+0000",
8 "state" : "UploadComplete",
9 "concurrencyMode" : "Parallel",
10 "contentType" : "CSV",
11 "apiVersion" : 46.0,
12 "lineEnding" : "LF",
13 "columnDelimiter" : "COMMA"
14}Response Parameters:
| Parameter | Description |
|---|---|
| id | The unique ID for this job. |
| operation | The type of query. |
| object | The object type being queried. |
| createdById | The ID of the user who created the job. |
| createdDate | The UTC date and time when the job was created. |
| systemModstamp | The UTC date and time when the API last updated the job information. |
| state |
The current state of processing for the job. Possible values are:
|
| concurrencyMode | Reserved for future use. How the request is processed. Currently only parallel mode is supported. (When other modes are added, the API chooses the mode automatically. The mode isn’t user configurable.) |
| contentType | The format to be used for the results. Currently the only supported value is CSV. JunctionIdList fields and embedded lists can't be returned. |
| apiVersion | The API version that the job was created in. |
| lineEnding | The line ending used for CSV job data, marking the end of a data row. |
| columnDelimiter | The column delimiter used for CSV job data. |
Example
1curl --include --request POST \
2--header "Authorization: Bearer token" \
3--header "Accept: application/json " \
4--header "Content-Type: application/json" \
5--data '{
6 "operation": "query",
7 "query": "SELECT Id, Name FROM Account"
8}' \
9https://instance.salesforce.com/services/data/vXX.X/jobs/query1HTTP/1.1 200 OK
2{
3 "id" : "750R0000000zw4yIAA",
4 "operation" : "query",
5 "object" : "Account",
6 "createdById" : "005R0000000GiwjIAC",
7 "createdDate" : "2018-12-17T21:00:17.000+0000",
8 "systemModstamp" : "2018-12-17T21:00:17.000+0000",
9 "state" : "UploadComplete",
10 "concurrencyMode" : "Parallel",
11 "contentType" : "CSV",
12 "apiVersion" : 46.0,
13 "lineEnding" : "LF",
14 "columnDelimiter" : "COMMA"
15}