I am using Bulk API v2 Query job to query on data from Salesforce.

For example my SOQL is - select id, firstname, lastname, city, state, country from account

In the response I am expecting columns to be in same order as they are specified in query but this is not happening. We get result columns in same order in the Bulk API v1 but not in v2. Is there any solution to this?

1 Answer 1


This is a documented behavior of the Bulk API 2.0 that is dependent on API version. From Get Results for a Query Job:

In API version 50.0 and later, the order of the columns returned by the query is the same as the order you requested them. In version 49.0 and earlier, the order of the columns is returned alphabetically.

Just upgrade your API version if you want to change the behavior.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .