I am trying to get more than 2,000 records from salesforce using Rest Api.


As I am getting the total size of records, but shows only 2,000.

Any suggestion how to get the records more than 2,000.

  • Maximum number of rows returned by SOQL queries over the REST API is 2000. So a possible workaround would be getting total count of records and use REST API with multiple times with query containing LIMIT and OFFSET based on total count. Nov 1 '19 at 6:37
  • This won't work. OFFSET also has a limit of 2000.
    – bpilling
    May 10 '21 at 12:27

The documentation should likely be your first stop when you have a question.

If you take a look at Execute a SOQL Query from the REST API documentation, at the bottom, we see this

Retrieving the Remaining SOQL Query Results

If the initial query returns only part of the results, the end of the response will contain a field called nextRecordsUrl. For example, you might find this attribute at the end of your query:

 "nextRecordsUrl" : "/services/data/v20.0/query/01gD0000002HU6KIAW-2000"

In such cases, request the next batch of records and repeat until all records have been retrieved. These requests use nextRecordsUrl, and do not include any parameters.

Example usage for retrieving the remaining query results

curl https://yourInstance.salesforce.com/services/data/v20.0/query/01gD0000002HU6KIAW-2000 -H "Authorization: Bearer token"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.