Newer Version Available

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

Step 4: Bulk Insert with a Multipart Request

This Bulk API 2.0 example guides you through creating a job to insert new records, uploading data for the job, checking 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 tits CSV data.

  1. 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.

    Note

  2. Create a job.

    URI

    Example of creating a job

    The response includes the job id, with a job state of UploadComplete. You use the job id in the next steps.

    Example response body

    After you create a multipart job, it’s closed automatically. You don’t need to manually close the job.
  3. Check the job status and results with this URI.

    URI

    Example of checking job status and results

    Example response body

  4. Get successful results.

    After a job is in the JobComplete or Failed state, 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 failedResults resource. To make sure that you’re looking at the complete result set, look at unprocessed records by using the unprocessedRecords resource. See Get Job Unprocessed Record Results.