Salesforce - Bulk API
Bulk 2.0 API
The Bulk 2.0 API has a simplified model over the original Bulk API. Use it to quickly load a large amount of data into salesforce, or query a large amount of data out of salesforce. Data must be provided in CSV format, usually via an InputStream instance. PK chunking is performed automatically. The minimum API version for Bulk 2.0 is v41.0. The minimum API version for Bulk Queries is v47.0. DTO classes mentioned below are from the org.apache.camel.component.salesforce.api.dto.bulkv2 package. The following operations are supported:
-
bulk2CreateJob - Creates a bulk ingest job.
-
bulk2CreateBatch - Adds a batch of data to an ingest job.
-
bulk2CloseJob - Closes an ingest job.
-
bulk2AbortJob - Aborts an ingest job.
-
bulk2DeleteJob - Deletes an ingest job.
-
bulk2GetSuccessfulResults - Gets successful results for an ingest job.
-
bulk2GetFailedResults - Gets failed results for an ingest job.
-
bulk2GetUnprocessedRecords - Gets unprocessed records for an ingest job.
-
bulk2GetJob - Gets an ingest Job.
-
bulk2GetAllJobs - Gets all ingest jobs.
-
bulk2CreateQueryJob - Creates a query job.
-
bulk2GetQueryJobResults - Gets query job results.
-
bulk2AbortQueryJob - Aborts a query job.
-
bulk2DeleteQueryJob - Deletes a query job.
-
bulk2GetQueryJob - Gets a query job.
-
bulk2GetAllQueryJobs - Gets all query jobs.
Create a Job
bulk2CreateJob Creates a bulk ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Job to create | x |
Output
Type: Job
Upload a Batch of Job Data
bulk2CreateBatch
Adds a batch of data to an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| CSV data. The first row must contain headers. | Required if | |
|
| Id of Job to create batch under | x |
Close a Job
bulk2CloseJob
Closes an ingest job. You must close the job in order for it to be processed or aborted/deleted.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to close | x |
Output
Type: Job
Abort a Job
bulk2AbortJob
Aborts an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to abort | x |
Output
Type: Job
Delete a Job
bulk2DeleteJob
Deletes an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to delete | x |
Get Job Successful Record Results
bulk2GetSuccessfulResults
Gets successful results for an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to get results for | x |
Output
Type: InputStream
Contents: CSV data
Get Job Failed Record Results
bulk2GetFailedResults
Gets failed results for an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to get results for | x |
Output
Type: InputStream
Contents: CSV data
Get Job Unprocessed Record Results
bulk2GetUnprocessedRecords
Gets unprocessed records for an ingest job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to get records for | x |
Output
Type: InputStream Contents: CSV data
Get Job Info
bulk2GetJob
Gets an ingest Job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Will use Id of supplied Job to retrieve Job | Required if | |
|
| Id of Job to retrieve | Required if |
Output
Type: Job
Get All Jobs
bulk2GetAllJobs
Gets all ingest jobs.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Used in subsequent calls if results span multiple pages |
Output
Type: Jobs
If the done property of the Jobs instance is false, there are additional pages to fetch, and the nextRecordsUrl property contains the value to be set in the queryLocator parameter on subsequent calls.
Create a Query Job
bulk2CreateQueryJob
Gets a query job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| QueryJob to create | x |
Output
Type: QueryJob
Get Results for a Query Job
bulk2GetQueryJobResults
Get bulk query job results. jobId parameter is required. Accepts maxRecords and locator parameters.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to get results for | x | |
|
| The maximum number of records to retrieve per set of results for the query. The request is still subject to the size limits. If you are working with a very large number of query results, you may experience a timeout before receiving all the data from Salesforce. To prevent a timeout, specify the maximum number of records your client is expecting to receive in the maxRecords parameter. This splits the results into smaller sets with this value as the maximum size. | ||
|
| A string that identifies a specific set of query results. Providing a value for this parameter returns only that set of results. Omitting this parameter returns the first set of results. |
Output
Type: InputStream Contents: CSV data
Response message headers include Sforce-NumberOfRecords and Sforce-Locator headers. The value of Sforce-Locator can be passed into subsequent calls via the locator parameter.
Abort a Query Job
bulk2AbortQueryJob
Aborts a query job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to abort | x |
Output
Type: QueryJob
Delete a Query Job
bulk2DeleteQueryJob
Deletes a query job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to delete | x |
Get Information About a Query Job
bulk2GetQueryJob
Gets a query job.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to retrieve | x |
Output
Type: QueryJob
Get Information About All Query Jobs
bulk2GetAllQueryJobs
Gets all query jobs.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Used in subsequent calls if results span multiple pages |
Output
Type: QueryJobs
If the done property of the QueryJobs instance is false, there are additional pages to fetch, and the nextRecordsUrl property contains the value to be set in the queryLocator parameter on subsequent calls.
Bulk (original) API
Producer endpoints can use the following APIs. All Job data formats, i.e. xml, csv, zip/xml, and zip/csv are supported.
The request and response have to be marshalled/unmarshalled by the route. Usually the request will be some stream source like a CSV file, and the response may also be saved to a file to be correlated with the request.
The following operations are supported:
-
createJob - Creates a Salesforce Bulk Job.
-
getJob - Gets a Job using its Salesforce Id
-
closeJob - Closes a Job
-
abortJob - Aborts a Job
-
createBatch - Submits a Batch within a Bulk Job
-
getBatch - Gets a Batch using Id
-
getAllBatches - Gets all Batches for a Bulk Job Id
-
getRequest - Gets Request data (XML/CSV) for a Batch
-
getResults - Gets the results of the Batch when its complete
-
createBatchQuery - Creates a Batch from an SOQL query
-
getQueryResultIds - Gets a list of Result Ids for a Batch Query
-
getQueryResult - Gets results for a Result Id
Create a Job
createJob
Creates a Salesforce Bulk Job. PK Chunking is supported via the pkChunking* options. See an explanation here.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Job to create | x | |
|
| Whether to use PK Chunking | false | |
|
| |||
|
| |||
|
|
Output
Type: JobInfo
Get Job Details
getJob
Gets a Job
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job to get | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: JobInfo
Close a Job
closeJob
Closes a Job
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: JobInfo
Abort a Job
abortJob
Aborts a Job
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: JobInfo
Add a Batch to a Job
createBatch
Submits a Batch within a Bulk Job
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | x | |
|
| Content type of body. Can be XML, CSV, ZIP_XML or ZIP_CSV | x | |
|
| Batch data | x |
Output
Type: BatchInfo
Get Information for a Batch
getBatch
Get a Batch
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Id of Batch | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: BatchInfo
Get Information for All Batches in a Job
getAllBatches
Gets all Batches for a Bulk Job Id
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: List<JobInfo>
Get a Batch Request
getRequest
Gets Request data (XML/CSV) for a Batch
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Id of Batch | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: InputStream
Get Batch Results
getResults
Gets the results of the Batch when it’s complete
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Id of Batch | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: InputStream
Create Bulk Query Batch
createBatchQuery
Creates a Batch from an SOQL query
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Content type of body. Can be XML, CSV, ZIP_XML or ZIP_CSV | Required if | |
|
| SOQL query to be used for this batch | Required if not supplied in body | |
Body |
| Either | Required |
Output
Type: BatchInfo
Get Batch Results
getQueryResultIds
Gets a list of Result Ids for a Batch Query
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Id of Batch | Required if body not supplied | |
Body |
|
| Required if |
Output
Type: List<String>
Get Bulk Query Results
getQueryResult
Gets results for a Result Id
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Id of Job | Required if body not supplied | |
|
| Id of Batch | Required if body not supplied | |
|
| Id of Result | If not passed in body | |
Body |
|
|
|
Output
Type: InputStream
For example, the following producer endpoint uses the createBatch API to create a Job Batch. The in message must contain a body that can be converted into an InputStream (usually UTF-8 CSV or XML content from a file, etc.) and header fields 'jobId' for the Job and 'contentType' for the Job content type, which can be XML, CSV, ZIP_XML or ZIP_CSV. The put message body will contain BatchInfo on success, or throw a SalesforceException on error.
...to("salesforce:createBatch")..