You need to sign in to do that
Don't have an account?
Jennifer BERNARD
All Query Jobs number of records in response (Bulk API 2.0)
Hello everyone.
I'm trying to get all jobs records using this URL:
According to the documentation I should be able to get 1000 records per request by default:
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_all_jobs.htm?q=get%20all%20jobs
But when I run the query (using Postman), I get 200 records. How can I change the number of records in the response ?
I'm trying to get all jobs records using this URL:
https://my.org.my.salesforce.com/services/data/v58.0/jobs/query
According to the documentation I should be able to get 1000 records per request by default:
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_all_jobs.htm?q=get%20all%20jobs
But when I run the query (using Postman), I get 200 records. How can I change the number of records in the response ?
Thank you for you answer ! I have already tried setting maxRecords as a query parameters as followed: But got the following response (JSON):
I guess this is working only when we try to get the result of a Job, not when we retrieve all the jobs ?
SOLUTION: Actually, I've found how to retrieve 1000 records with each request, it's by using the API version 56.0 instead of 58.0. Apparently from API version 57.0, this request only retrieve 200 records by default. I will check the update releases pages for REST API to see if something can be done to filter the response with newer version, the documentation for Bulk API doesn't seem up-to-date yet.
All Answers
As explained in the Bulk API V2 “Get Results for a Query Job” document,(https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_job_results.htm) you need to use locator and maxRecords optional parameters to get query results.
For example, when you perform /services/data/v56.0/jobs/query/7507Q00000B4aRyQAJ/results GET call, it returns below response:
Notice, Sforce-Locator: MQ and Sforce-NumberOfRecords: 1 in the response.
The locator value sent in the 1st set of results needs to be used in the subsequent call to get the next set of results until you see Sforce-Locator: null in the response.
For example, if you send /services/data/v56.0/jobs/query/7507Q00000B4aRyQAJ/results?locator=MQ GET call again, it results all the remaining results and you would notice Sforce-Locator: null in the response header which means all the records have been returned.
Apart from it, you can set maxRecords=maxRecords parameter to retrieve specific number of records, e.g. when I make /services/data/v56.0/jobs/query/7507Q00000B4aRyQAJ/results?maxRecords=1000 call, it returns 1000 records with Sforce-Locator: MTAw to retrieve next set of results.
Related:https://salesforce.stackexchange.com/questions/85967/rest-api-list-view-results-25-record-limit
If this information helps, please mark the answer as best. Thank you
Thank you for you answer ! I have already tried setting maxRecords as a query parameters as followed: But got the following response (JSON):
I guess this is working only when we try to get the result of a Job, not when we retrieve all the jobs ?
SOLUTION: Actually, I've found how to retrieve 1000 records with each request, it's by using the API version 56.0 instead of 58.0. Apparently from API version 57.0, this request only retrieve 200 records by default. I will check the update releases pages for REST API to see if something can be done to filter the response with newer version, the documentation for Bulk API doesn't seem up-to-date yet.