0

Suppose I send a GET request to the following endpoint:

/services/data/v39.0/sobjects/Contact/Email/test@email.com

If there is only one contact with that email, the response I get from the API contains all the fields for that contact. But if there is more than one match, the response looks like this:

[
  "/services/data/v39.0/sobjects/Contact/00Q6F0000144bUxUAI",
  "/services/data/v39.0/sobjects/Contact/00Q6F0000144bEFUAY"
]

Is there any way to force the initial request to always return the fields from the first contact, ignoring the rest?

Otherwise I need to look into the response, extract the contact ID, and make a second GET request, which I really would love to avoid.

Any ideas? Thanks!

  • Why not run a SOQL using Rest api, you can add LIMIT 1 there? – Santanu Halder Apr 6 '17 at 7:04
  • As far as I know, I can't do SELECT * FROM Contacts. I'd rather not have to manually build the query. But no other reason, to be honest. If it's the only way to get all the results I need in a single query I might just go that way... Thanks @SantanuHalder! – Alex Apr 6 '17 at 7:11
  • You don't have to write the SOQL Query manually, you can use Dynamic SOQL to fetch all fields. Please check this link. – Saroj Bera Apr 6 '17 at 8:56

Your Answer

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

Browse other questions tagged or ask your own question.