Overview

Bulk API operates in terms of a two-tier system of containers to track units of data movement work. Each tier is described here:

Image Batch—A batch is a set of records to be imported. The records are represented in CSV or XML format. For import jobs, a batch cannot exceed 10,000 records. Batches are not applicable to export jobs, which use result files that cannot exceed 1GB.

Image Job—A job is a list of batches. The job specifies the type of operation that will be performed in the batches, such as insert or query.

Authentication

Bulk REST API calls require authentication to Force.com. Use the username-password OAuth flow, which accepts username and password, to establish an authenticated session. Listing 11.3 provides a sample request and response.

Listing 11.3 Sample Password Authentication Request and Response


curl https://login.salesforce.com/services/oauth2/token
  -d "grant_type=password" -d "client_id=$CLIENT_ID"
  -d "client_secret=$CLIENT_SECRET"
  -d "username=$USERNAME" -d "password=$PASSWORD"
{
    "id": "https://login.salesforce.com/id/...",
    "issued_at": "1374386510993",
    "instance_url": "https://na15.salesforce.com",
    "signature": "...",
    "access_token": "..."
}


The value in the response’s access_token field is needed to run all of the examples in this section. To get one yourself, set the $USERNAME environment variable to your Salesforce username, $PASSWORD to your Salesforce password with security token appended. The variables $CLIENT_ID and $CLIENT_SECRET are your OAuth Consumer Key and Consumer Secret. These come from a Connected App, which you can reuse from Chapter 10, “Integration with Force.com.”

Now that you have obtained an OAuth access token, you are ready to try the Bulk API examples. Set the access token as the environment variable $TOKEN. Also, be sure to replace na15 in the following examples with your own instance of Force.com. To identify your instance, look at the instance_url field of the OAuth username-password flow, or the URL in your Web browser when you log in to Force.com.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.188.201