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.
Walk Through a Bulk Query Sample
Create a Job
- Create a file called create-job.xml containing this
text.
1<?xml version="1.0" encoding="UTF-8"?> 2<jobInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <operation>query</operation> 5 <object>Account</object> 6 <concurrencyMode>Parallel</concurrencyMode> 7 <contentType>CSV</contentType> 8</jobInfo> - 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/67.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.
1<?xml version="1.0" encoding="UTF-8"?> 2<jobInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <id>750x000000009tvAAA</id> 5 <operation>query</operation> 6 <object>Account</object> 7 <createdById>005x0000001WR0lAAG</createdById> 8 <createdDate>2016-01-10T00:53:19.000Z</createdDate> 9 <systemModstamp>2016-01-10T00:53:19.000Z</systemModstamp> 10 <state>Open</state> 11 <concurrencyMode>Parallel</concurrencyMode> 12 <contentType>CSV</contentType> 13 <numberBatchesQueued>0</numberBatchesQueued> 14 <numberBatchesInProgress>0</numberBatchesInProgress> 15 <numberBatchesCompleted>0</numberBatchesCompleted> 16 <numberBatchesFailed>0</numberBatchesFailed> 17 <numberBatchesTotal>0</numberBatchesTotal> 18 <numberRecordsProcessed>0</numberRecordsProcessed> 19 <numberRetries>0</numberRetries> 20 <apiVersion>36.0</apiVersion> 21 <numberRecordsFailed>0</numberRecordsFailed> 22 <totalProcessingTime>0</totalProcessingTime> 23 <apiActiveProcessingTime>0</apiActiveProcessingTime> 24 <apexProcessingTime>0</apexProcessingTime> 25</jobInfo>
Add a Batch to the Job
- Create a file called query.txt to contain the SOQL query
statement.
1SELECT Id, Name FROM Account LIMIT 10 - 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/67.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.
1<?xml version="1.0" encoding="UTF-8"?> 2<batchInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <id>751x000000009vwAAA</id> 5 <jobId>750x000000009tvAAA</jobId> 6 <state>Queued</state> 7 <createdDate>2016-01-10T00:59:47.000Z</createdDate> 8 <systemModstamp>2016-01-10T00:59:47.000Z</systemModstamp> 9 <numberRecordsProcessed>0</numberRecordsProcessed> 10 <numberRecordsFailed>0</numberRecordsFailed> 11 <totalProcessingTime>0</totalProcessingTime> 12 <apiActiveProcessingTime>0</apiActiveProcessingTime> 13 <apexProcessingTime>0</apexProcessingTime> 14</batchInfo>
Close the Job
- Create a file called close-job.xml containing this
text.
1<?xml version="1.0" encoding="UTF-8"?> 2<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 3 <state>Closed</state> 4</jobInfo> - 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/67.0/job/jobId
Salesforce returns an XML response with data such as this.
1<?xml version="1.0" encoding="UTF-8"?> 2<jobInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <id>750x000000009tvAAA</id> 5 <operation>query</operation> 6 <object>Account</object> 7 <createdById>005x0000001WR0lAAG</createdById> 8 <createdDate>2016-01-10T00:53:19.000Z</createdDate> 9 <systemModstamp>2016-01-10T00:53:19.000Z</systemModstamp> 10 <state>Closed</state> 11 <concurrencyMode>Parallel</concurrencyMode> 12 <contentType>CSV</contentType> 13 <numberBatchesQueued>0</numberBatchesQueued> 14 <numberBatchesInProgress>0</numberBatchesInProgress> 15 <numberBatchesCompleted>1</numberBatchesCompleted> 16 <numberBatchesFailed>0</numberBatchesFailed> 17 <numberBatchesTotal>1</numberBatchesTotal> 18 <numberRecordsProcessed>10</numberRecordsProcessed> 19 <numberRetries>0</numberRetries> 20 <apiVersion>36.0</apiVersion> 21 <numberRecordsFailed>0</numberRecordsFailed> 22 <totalProcessingTime>0</totalProcessingTime> 23 <apiActiveProcessingTime>0</apiActiveProcessingTime> 24 <apexProcessingTime>0</apexProcessingTime> 25</jobInfo>
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/67.0/job/jobId
Salesforce returns an XML response with data such as this.
1<?xml version="1.0" encoding="UTF-8"?> 2<jobInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <id>750x000000009tvAAA</id> 5 <operation>query</operation> 6 <object>Account</object> 7 <createdById>005x0000001WR0lAAG</createdById> 8 <createdDate>2016-01-10T00:53:19.000Z</createdDate> 9 <systemModstamp>2016-01-10T00:53:19.000Z</systemModstamp> 10 <state>Open</state> 11 <concurrencyMode>Parallel</concurrencyMode> 12 <contentType>CSV</contentType> 13 <numberBatchesQueued>0</numberBatchesQueued> 14 <numberBatchesInProgress>0</numberBatchesInProgress> 15 <numberBatchesCompleted>1</numberBatchesCompleted> 16 <numberBatchesFailed>0</numberBatchesFailed> 17 <numberBatchesTotal>1</numberBatchesTotal> 18 <numberRecordsProcessed>10</numberRecordsProcessed> 19 <numberRetries>0</numberRetries> 20 <apiVersion>36.0</apiVersion> 21 <numberRecordsFailed>0</numberRecordsFailed> 22 <totalProcessingTime>0</totalProcessingTime> 23 <apiActiveProcessingTime>0</apiActiveProcessingTime> 24 <apexProcessingTime>0</apexProcessingTime> 25</jobInfo> - 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/67.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.
1<?xml version="1.0" encoding="UTF-8"?> 2<batchInfo 3 xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 4 <id>751x000000009vwAAA</id> 5 <jobId>750x000000009tvAAA</jobId> 6 <state>Completed</state> 7 <createdDate>2016-01-10T00:59:47.000Z</createdDate> 8 <systemModstamp>2016-01-10T01:00:19.000Z</systemModstamp> 9 <numberRecordsProcessed>10</numberRecordsProcessed> 10 <numberRecordsFailed>0</numberRecordsFailed> 11 <totalProcessingTime>0</totalProcessingTime> 12 <apiActiveProcessingTime>0</apiActiveProcessingTime> 13 <apexProcessingTime>0</apexProcessingTime> 14</batchInfo>
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/67.0/job/jobId/batch/batchId/result
Salesforce returns an XML response with data such as this.
1<?xml version="1.0" encoding="UTF-8"?> 2<result-list xmlns="http://www.force.com/2009/06/asyncapi/dataload"> 3 <result>752x00000004CJE</result> 4</result-list> - 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/67.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.
1"Id","Name" 2"001x000xxx4TU4JAAW","name161268--1296595660659" 3"001x000xxx4TU4KAAW","name161269--1296595660659" 4"001x000xxx4TU4LAAW","name161270--1296595660659" 5"001x000xxx4TU4MAAW","name161271--1296595660659" 6"001x000xxx4TU4NAAW","name161272--1296595660659" 7"001x000xxx4TU4OAAW","name161273--1296595660659" 8"001x000xxx4TU4PAAW","name161274--1296595660659" 9"001x000xxx4TU4QAAW","name161275--1296595660659" 10"001x000xxx4TU4RAAW","name161276--1296595660659" 11"001x000xxx4TU4SAAW","name161277--1296595660659"