Newer Version Available

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

Step 2: Creating a Job

Before you can load any data, you first have to 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, 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.

To create a job using cURL:

  1. Create a text file called job.txt containing the following 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 be all lower case. 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/33.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.

    Salesforce returns an XML response with data such as the following:

    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>33.0</apiVersion>
    21</jobInfo>
  3. Note the value of the job ID returned in the <id> element. Use this ID in subsequent operations.