0

The SOAP API supports a "retrieve()" method that returns all records whose ID's are in some given list of ID's. Is there an equivalent in the REST API?

The closest I could find was https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm but that only allows me to specify a single ID.

1

You can use the Query resource to execute a SOQL query via REST API that returns all the results in a single response. You can append all the ids in a comma separated list as below. But Salesforce has a limitation of 4,000 characters for Maximum length of SOQL WHERE clause.

https://yourInstance.salesforce.com/services/data/v39.0/query/?q=SELECT+name+from+Account+WHERE+Id+In+('001i000000gDY4a','001i000000gDY4c')
  • Thanks Saroj for the response. If the character limit is an issue, do you think I can use the Composite API: developer.salesforce.com/docs/atlas.en-us.api_rest.meta/… to make a series of such Query requests? That way, if the number of ID's I want to retrieve exceeds the character limit, I can partition the list into sublists and make the Query request for each sublist within a Composite API call. – user2510927 Jun 23 '17 at 22:02

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.