Newer Version Available

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

Use Bulk Query

When you add a batch to a bulk query job, the Content-Type in the header for the request must be text/csv, application/xml, or application/json, depending on the content type specified when the job was created. The actual SOQL statement supplied for the batch is in plain text format.
URI
/services/async/APIversion/job/jobid/batch
Bulk Query Request

Bulk API query supports both query and queryAll operations. The queryAll operation returns records that have been deleted because of a merge or delete. The queryAll operation also returns information about archived Task and Event records. For more information, see queryAll() in the SOAP API Developer Guide.

Relationship queries traverse parent-to-child and child-to-parent relationships between objects to filter and return results. You can use SOQL relationships in bulk queries. For more information about SOQL relationships, see Using Relationship Queries in the SOQL and SOSL Reference.

Bulk API doesn’t support queries with any of the following:
  • GROUP BY, OFFSET, or TYPEOF clauses
  • Aggregate functions such as COUNT()
  • Date functions in GROUP BY clauses (date functions in WHERE clauses are supported)
  • Compound address fields or compound geolocations fields

Requests, and Responses

These are example Bulk Query requests and responses.

Create Bulk Query Batch HTTP Request
Create Bulk Query Batch HTTP Response Body
Get Batch Information for All Batches in a Job HTTP Request (used when PK chunking is enabled)
Get Batch Information for All Batches in a Job HTTP Response Body
Get Batch Results HTTP Request
Get Batch Results HTTP Response Body
Get Bulk Query Results HTTP Request
Get Bulk Query Results HTTP Response Body
XML Responses for Queries that Include ID
If you use XML for the ContentType of a Query Job, then a query that includes ID returns the ID field twice in the XML response data. Similarly, a query that does not include ID returns a single null ID field in the XML response data. For example, a query for SELECT ID, FirstName, LastName FROM Contact might return an XML response with records like:
This is expected behavior and something to be aware of if you are accessing the full XML response data and not using WSC to access the web service response. For more information, see Queries and the Partner WSDL in the SOAP API Developer Guide.

Java Example Using WSC

This example logs in to an organization using the Partner API, then instantiates a BulkConnection object using the service endpoint from the Partner API login.