Newer Version Available
Walk Through a Bulk Query Sample
Create a Job
- Create a file called create-job.xml containing this
text.
- Using a command-line window, execute this cURL command to create a job.
curl -H "X-SFDC-Session: sessionId" -H "Content-Type: application/xml; charset=UTF-8" -d @create-job.xml https://instance.salesforce.com/services/async/60.0/job
instance is the portion of the <serverUrl> element and sessionId is the <sessionId> element that you noted in the login response.
Salesforce returns an XML response with data such as this.
Add a Batch to the Job
- Create a file called query.txt to contain the SOQL query
statement.
- Using a command-line window, execute this cURL command to add a batch to the job:
curl -d @query.txt -H "X-SFDC-Session: sessionId" -H "Content-Type: text/csv; charset=UTF-8" https://instance.salesforce.com/services/async/60.0/job/jobId/batch
jobId is the job ID returned in the response to the job creation.
Salesforce returns an XML response with data such as this.
Close the Job
- Create a file called close-job.xml containing this
text.
- Using a command-line window, execute this cURL command to close the job.
curl -H "X-SFDC-Session: sessionId" -H "Content-Type: text/csv; charset=UTF-8" -d @close-job.xml https://instance.salesforce.com/services/async/60.0/job/jobId
Salesforce returns an XML response with data such as this.
Check the Status of the Job and Batch
- Using a command-line window, execute this cURL command to check the job
status.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/60.0/job/jobId
Salesforce returns an XML response with data such as this.
- Using a command-line window, execute this cURL command to check the batch
status.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/60.0/job/jobId/batch/batchId
batchId is the batch ID in the response to the batch creation.
Salesforce returns an XML response with data such as this.
Retrieve the Results
- Using the command-line window, execute this cURL command to retrieve the batch result
list.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/60.0/job/jobId/batch/batchId/result
Salesforce returns an XML response with data such as this.
- Using the command-line window, execute this cURL command to retrieve the results of the
query.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/60.0/job/jobId/batch/batchId/result/resultId
resultId is the result ID in the response to the batch result list request.
Salesforce returns a CSV response with data such as this.