Step 4: Bulk Insert with a Multipart Request
This Bulk API 2.0 example guides you through creating a job, uploading data for the job, checking the status, and retrieving the results. This example uses a single, multipart request to create the job and upload the data.
In this example, BOUNDARY is used at the start, middle, and end of the file to mark the request body boundaries between the job’s details and its CSV data.
-
Copy this multipart, JSON-formatted content into a file named
newmultipartjob.json.Save all files in this example in your terminal’s current working directory.
-
Create a job.
URI
Example of creating a job
The response includes the job
id, with a jobstateofUploadComplete. You use the jobidin the next steps.Example response body
After you create a multipart job, the upload is completed for you automatically. You don’t need to manually set the job
statetoUploadCompletefor a multipart job. -
Check the job status and results with this URI.
URI
Example of checking job status and results
Example response body
-
Get successful results.
After a job is in the
JobCompleteorFailedstate, you can get details about which records were successfully processed.URI
Example of getting successful results
Example response body
To get details about records that encountered an error during processing, use a GET request with the
failedResultsresource. To make sure that you’re looking at the complete result set, look at unprocessed records by using theunprocessedRecordsresource. See Get Job Unprocessed Record Results.