Get Results for a Query Job
Syntax
- URI
- /services/data/vXX.X/jobs/query/queryJobId/results
-
- Available since release
-
This resource is available in API version 47.0 and later.
- Formats
- CSV
- HTTP methods
- GET
- Authentication
- Authorization: OAuth sessionId
- Request parameters
-
Parameter Description Required or Optional queryJobId The ID of the query job. Required locator Gets a specific set of results. If this is omitted, the request returns as many rows as can be listed. If there are more results than can be listed, the Sforce-Locator header contains a locator value to get the next set of results.
See Rules and Guidelines.
Optional maxRecords The maximum number of records to retrieve per set. The request is still subject to the size limits. If you are working with very large query result sets, you may experience a timeout before receiving all the data from Salesforce. To prevent a timeout, specify the maximum number of records your client is expecting to receive by in the maxRecords parameter. This splits the results into smaller sets.
Optional - Response Body
- If the request is successful, the status code is 200 (OK) and the request body contains the
results of the job’s query. For
example:
- Response For an Unsuccessful Request
- If the request fails, the status code is 204 (No Content).
- Response Headers
-
Header Description Sforce-NumberOfRecords The number of records in this set. Sforce-Locator The URI to get the next set of results. See Rules and Guidelines.
If there are no more results, this header is null.
Example
The
following retrieves the results for the job with ID 750R0000000zxr8IAA.
The response body
is:
Rules and Guidelines
- Use /services/data/vXX.X/jobs/query/queryJobId/results to get the first set of results for the job.
- If there are more results than can be listed, the Sforce-Locator response header will be non-null. Set the locator to that value to get the next set of results.
- Repeat this process until the Sforce-Locator header is null. That set is the last set of results.