Newer Version Available
Walk Through a Bulk Query Sample
Create a Job
- Create a file called create-job.xml containing the following
text.
- Using a command-line window, execute the following 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/37.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 the following.
Add a Batch to the Job
- Create a file called query.txt to contain the SOQL query
statement.
- Using a command-line window, execute the following 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/37.0/job/jobId/batch
jobId is the job ID returned in the response to the job createion.
Salesforce returns an XML response with data such as the following.
Check the Status of the Job and Batch
- Using a command-line window, execute the following cURL command to check the job
status.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/37.0/job/jobId
Salesforce returns an XML response with data such as the following.
- Using a command-line window, execute the following cURL command to check the batch
status.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/37.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 the following.
Retrieve the Results
- Using the command-line window, execute the following cURL command to retrieve the batch
result list.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/37.0/job/jobId/batch/batchId/result
Salesforce returns an XML response with data such as the following.
- Using the command-line window, execute the following cURL command to retrieve the
results of the query.
curl -H "X-SFDC-Session: sessionId" https://instance.salesforce.com/services/async/37.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 the following.
Close the Job
- Create a file called close-job.xml containing the following
text.
- Using a command-line window, execute the following 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/37.0/job
Salesforce returns an XML response with data such as the following.