Skip to content
Michael Shattuck edited this page Feb 27, 2015 · 1 revision

Interaction with the Bulk API is slightly different than using the SOAP API. In order to use the bulk api you'll need to start a data load job:

JobInfo jobInfo = client.CreateBulkJob<vAttachment>(new JobConfig
{
    ConcurrencyMode = ConcurrencyMode.Parallel,
    Operation = BulkOperations.Insert
});

Starting a job will return a JobInfo object:

public class JobInfo
{
    public string Id { get; set; }
    public string Operation { get; set; }
    public string Object { get; set; }
    public string CreatedById { get; set; }
    public DateTime CreatedDate { get; set; }
    public JobState State { get; set; }
    public ConcurrencyMode ConcurrencyMode { get; set; }
    public string ContentType { get; set; }
    public int NumberBatchedQueued { get; set; }
    public int NumberBatchedInProgress { get; set; }
    public int NumberBatchedCompleted { get; set; }
    public int NumberBatchedFailed { get; set; }
    public int NumberBatchedTotal { get; set; }
    public int NumberBatchedProcessed { get; set; }
    public int NumberRetries { get; set; }
    public string ApiVersion { get; set; }
}

The most important part of the object is the Id. This is used to add batches to the job:

BatchInfo batchInfo = client.AddBatch(attachments, jobInfo.Id);

This will queue a batch operation in the specified job. It returns a BatchInfo object:

public class BatchInfo
{
    public string Id { get; set; }
    public string JobId { get; set; }
    public string State { get; set; }
    public DateTime CreatedDate { get; set; }
    public int NumberRecordsProcessed { get; set; }
}

Once you have added the necessary batches to the job you will need to close it:

SalesforceResponse jobCloseResponse = client.CloseBulkJob(jobInfo.Id);
Clone this wiki locally