function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GWI EngineeringGWI Engineering 

Get multiple records using EXTERNAL IDS

Hi there,
Anyone know the best way to get multiple records using the same EXTERNAL_ID?
Our case is that we have more than one Salesforce contact using the same email (external_id) and the follow request is causing 300 Multiple Choices:

```

curl https://yourInstance.salesforce.com/services/data/v20.0/sobjects/Contact/Email/foo@example.com -H "Authorization: Bearer token"

```

 

Thanks for your time.

Juan Ramon Cañizares Gomez.

Best Answer chosen by GWI Engineering
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

There is no easy way to do it as the wildcard (*) is not allowed in SOQL queries and, believe me, it makes sense in terms of performance. What you can do is declare them manually or query the describe of the sObject first and get all queriable fields before making the callout to retrieve the records.

User-added image

Hope to have helped!

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.

All Answers

Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

Trying using a query instead, it would look like:
https://yourInstance.salesforce.com/services/data/v20.0/query/?q=SELECT+name,email,phone+from+Contact

See more at: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

Hope to have helped!

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
GWI EngineeringGWI Engineering

Hi Zuinglio,

 

Thanks for the quick reply, I think that can work fine. Any ideas of how to SELECT all the attributes at once?

 

Juan Ramon Cañizares Gomez.

Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

There is no easy way to do it as the wildcard (*) is not allowed in SOQL queries and, believe me, it makes sense in terms of performance. What you can do is declare them manually or query the describe of the sObject first and get all queriable fields before making the callout to retrieve the records.

User-added image

Hope to have helped!

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
This was selected as the best answer
GWI EngineeringGWI Engineering
Hi Zuinglio,

That makes sense, thanks.