Execute a SOQL Query
Use the Query
resource to execute a SOQL query that returns all the results in a single response, or
if needed, returns part of the results and a locator used to retrieve the remaining
results.
The following query requests the value from name fields from all Account records.
- Example usage for executing a query
-
curl https://MyDomainName.my.salesforce.com/services/data/v63.0/query/?q=SELECT+name,id+from+Account -H "Authorization: Bearer token"
- Example request body for executing a query
- none required
- Example response body for executing a query
-
{ "done" : true, "totalSize" : 14, "records" : [ { "attributes" : { "type" : "Account", "url" : "/services/data/v63.0/sobjects/Account/001D000000IRFmaIAH" }, "Name" : "Test 1" }, { "attributes" : { "type" : "Account", "url" : "/services/data/v63.0/sobjects/Account/001D000000IomazIAB" }, "Name" : "Test 2" }, ... ] }
Retrieving the Remaining SOQL Query Results
If the initial query returns only part of the results, the end of the response
contains a field called nextRecordsUrl:
"nextRecordsUrl" : "/services/data/v63.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 don't include any parameters.
- Example usage for retrieving the remaining query results
-
curl https://MyDomainName.my.salesforce.com/services/data/v63.0/query/01gD0000002HU6KIAW-2000 -H "Authorization: Bearer token"
- Example request body for retrieving the remaining query results
- none required
- Example response body for retrieving the remaining query results
-
{ "done" : true, "totalSize" : 3214, "records" : [...] }