Newer Version Available

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

Creating a Job for Batches with Binary Attachments

This section describes how to use cURL to create a job for batches containing Attachment records. For more information on cURL, see Sending HTTP Requests with cURL.

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>Attachment</object>
    5    <contentType>ZIP_CSV</contentType>
    6</jobInfo>

    The batches for this job contain data in CSV format so the contentType field is set to ZIP_CSV. For XML batches, use ZIP_XML instead.

    Note

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

    curl https://instance.salesforce.com/services/async/30.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. For more information about logging in, see Step 1: Logging In Using the SOAP API.

    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>750D000000001SRIAY</id>
    5  <operation>insert</operation>
    6  <object>Attachment</object>
    7  <createdById>005D0000001B0VkIAK</createdById>
    8  <createdDate>2010-08-25T18:52:03.000Z</createdDate>
    9  <systemModstamp>2010-08-25T18:52:03.000Z</systemModstamp>
    10  <state>Open</state>
    11  <concurrencyMode>Parallel</concurrencyMode>
    12  <contentType>ZIP_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>30.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.