3

I am getting 20 contact ID from getUpdated.Now I need information for each of these 20 contacts.It seems costly to request each contact through a REST url.Is there any way how I can query multiple contacts through 1 url?
Is the bulk api designed for this?If so,how does the url looks like?I assue it is a REST url too.

1
  • Everything you need to know about the bulk api here: salesforce.com/us/developer/docs/api_asynch - You could also creat your own rest endpoint to return the data you need. Otherwise the REST API is single record only
    – Eric
    Commented Jan 25, 2015 at 5:54

2 Answers 2

2

It sounds like you're using the the /sobjects/<type>/<id> endpoint you'll need to switch to the query endpoint (/query/?q=<query>) to make use of this.

SOQL Supports using an IN operator here. If your current query looks like, say, SELECT id, name, ownerId FROM Contact WHERE Id = 'someId' you could use IN as: SELECT id, name, ownerId FROM Contact WHERE Id IN ('firstId', 'secondId')

Having one item in the parentheses is fine, and works just like equals then. You also can use this multi-item syntax with equals (=) but using the IN operator makes your intentions more clear to future readers so I always recommend it.

3

You can write your APEX class and then expose that as a REST resource .Let me draft a simple example to help you with

@RestResource(urlMapping='/retrieveContacts/*')
 global with sharing class MyRestResource {

  @HttpPost
     global static list<Contact> doPost(List<Id> lstcontactId) {
      return [Select id,name,fax,Phone,Email from Contact where Id IN:lstcontactId];
     }
 }

This will create a REST END POINT at /services/apexrest/retrieveContacts .You will need to input array of Contact Ids to this webservice

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .