- Bulk API is based on REST principles and is optimized for working with large sets of data.
- You can use it to insert, update, upsert, or delete many records asynchronously, meaning that you submit a request and come back for the results later. Salesforce processes the request in the background.
- The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. With Data Loader, you don’t have to write your own client app.
- Log in to your Trailhead DE org and navigate to Workbench.
- For Environment, select Production. For API Version, select the highest available number. Make sure that you select I agree to the terms of service.
- Click Login with Salesforce.
- In the top menu, select utilities | REST Explorer.
POST
request
- Endpoint url syntax
/services/data/vXX.0/jobs/ingest
- Example:
/services/data/v41.0/jobs/ingest
- Request body
{
"operation" : "insert",
"object" : "Account",
"contentType" : "CSV",
"lineEnding" : "CRLF"
}
- Execute
- Copy the Job ID (e.g. 7507F000003zdR5QAI)
PUT
request
- Endpoint url syntax
/services/data/vXX.0/jobs/ingest/jobID/batches
- Example:
/services/data/v41.0/jobs/ingest/7507F000003zdR5QAI/batches
- Request body
"Name"
"Sample Bulk API Account 1"
"Sample Bulk API Account 2"
"Sample Bulk API Account 3"
"Sample Bulk API Account 4"
- Request header
Content-Type: text/csv
Accept: application/json
- Execute
- This will process the data.
PATCH
request
- Endpoint url syntax
/services/data/vXX.0/jobs/ingest/jobID
- Example:
/services/data/v41.0/jobs/ingest/7507F000003zdR5QAI
- Request body
{
"state" : "UploadComplete"
}
- Request header
Content-Type: application/json
Accept: application/json
- Execute
- Check results
- If your state is still
UploadComplete
instead of JobComplete
, Salesforce is still processing the job. Don’t worry, it’ll be processed in a few minutes.
GET
request
- Endpoint url syntax
/services/data/vXX.0/jobs/ingest/jobID/successfulResults
- Example:
/services/data/v41.0/jobs/ingest/7507F000003zdR5QAI/successfulResults
- Execute
GET
request
- Endpoint url syntax
/services/data/vXX.0/jobs/ingest/jobID/failedResults
- Example:
/services/data/v41.0/jobs/ingest/7507F000003zdR5QAI/failedResults
- Execute