Newer Version Available

This content describes an older version of this product. View Latest

Step 5: Check Batch Status

You can check the status of an individual batch by running the following cURL command.

curl https://instance.salesforce.com/services/async/44.0/job/jobId/batch/batchId -H "X-SFDC-Session: sessionId"

instance is the portion of the <serverUrl> element and sessionId is the <sessionId> element that you noted in the login response. jobId is the job ID that was returned when you created the job. batchId is the batch ID that was returned when you added a batch to the job.

Salesforce returns an XML response with data such as the following:

1<?xml version="1.0" encoding="UTF-8"?>
2<batchInfo
3   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
4  <id>751x00000000079AAA</id>
5  <jobId>750x0000000005LAAQ</jobId>
6  <state>Completed</state>
7  <createdDate>2009-09-01T17:44:45.000Z</createdDate>
8  <systemModstamp>2009-09-01T17:44:45.000Z</systemModstamp>
9  <numberRecordsProcessed>2</numberRecordsProcessed>
10  <numberRecordsFailed>0</numberRecordsFailed>
11  <totalProcessingTime>5820</totalProcessingTime>
12  <apiActiveProcessingTime>2166</apiActiveProcessingTime>
13  <apexProcessingTime>0</apexProcessingTime>
14</batchInfo>

If Salesforce can’t read the batch content or if the batch contains errors, such as invalid field names in the CSV header row, the batch state is Failed. When the batch state is Completed, all records in the batch have been processed. However, individual records could have failed. You need to retrieve the batch result to see the status of individual records.

You don’t have to check the status of each batch individually. You can check the status for all batches that are part of the job by running the following cURL command:

curl https://instance.salesforce.com/services/async/44.0/job/jobId/batch -H "X-SFDC-Session: sessionId"