Newer Version Available

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

Step 2: Create a Job

Before you can load data, you first create a job. The job specifies the type of object, such as Contact, that you’re loading and the operation that you’re performing, such as query, queryAll, insert, update, upsert, or delete. A job also grants you some control over the data load process. For example, you can abort a job that is in progress.
  1. Create a text file called job.txt containing this text:
    1<?xml version="1.0" encoding="UTF-8"?>
    2<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
    3    <operation>insert</operation>
    4    <object>Contact</object>
    5    <contentType>CSV</contentType>
    6</jobInfo>

    The operation value must match that shown here. For example, you get an error if you use INSERT instead of insert.

    Warning

  2. Using a command-line window, execute the following cURL command:

    curl https://instance.salesforce.com/services/async/66.0/job -H "X-SFDC-Session: sessionId" -H "Content-Type: application/xml; charset=UTF-8" -d @job.txt

    instance is the portion of the <serverUrl> element and sessionId is the <sessionId> element that you noted in the login response.

    When running cURL examples, you can get an error on Mac and Linux systems due to the presence of the exclamation mark special character in the session ID argument. To avoid getting this error, either escape the exclamation mark by inserting a backslash before it (\!) or enclose the session ID within single quotes.

    Note

    Salesforce returns an XML response with data such as this:

    1<?xml version="1.0" encoding="UTF-8"?>
    2<jobInfo
    3   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
    4  <id>750x0000000005LAAQ</id>
    5  <operation>insert</operation>
    6  <object>Contact</object>
    7  <createdById>005x0000000wPWdAAM</createdById>
    8  <createdDate>2009-09-01T16:42:46.000Z</createdDate>
    9  <systemModstamp>2009-09-01T16:42:46.000Z</systemModstamp>
    10  <state>Open</state>
    11  <concurrencyMode>Parallel</concurrencyMode>
    12  <contentType>CSV</contentType>
    13  <numberBatchesQueued>0</numberBatchesQueued>
    14  <numberBatchesInProgress>0</numberBatchesInProgress>
    15  <numberBatchesCompleted>0</numberBatchesCompleted>
    16  <numberBatchesFailed>0</numberBatchesFailed>
    17  <numberBatchesTotal>0</numberBatchesTotal>
    18  <numberRecordsProcessed>0</numberRecordsProcessed>
    19  <numberRetries>0</numberRetries>
    20  <apiVersion>66.0</apiVersion>
    21  <numberRecordsFailed>0</numberRecordsFailed>
    22  <totalProcessingTime>0</totalProcessingTime>
    23  <apiActiveProcessingTime>0</apiActiveProcessingTime>
    24  <apexProcessingTime>0</apexProcessingTime>
    25</jobInfo>
  3. Note the value of the job ID returned in the <id> element. Use this ID in subsequent operations.