I'm creating a sync engine for a mobile app, and I want to get meta data about the state of a whole lot of different objects in as few API calls as possible. Is it possible to pass more than one SOQL statements in one API call or otherwise combine them? Or would I need to create an Apex class to integrate these different result sets into one Json? Is there a better way?


Perhaps one of the standard APIs can do this - if so hopefully someone will post that answer.

As far as creating your own class, this code compiles:

global with sharing class Reader {
    global static List<List<SObject>> post(List<String> soqls) {
        List<List<SObject>> results = new List<List<SObject>>();
        for (String soql : soqls) {
        return results;

and in theory will return the query results for each SOQL string passed in with the platform taking care of the serialization (to JSON or XML) using its default algorithms.

But if you care about the URL patterns part of REST, using a POST to just GET data is inappropriate. If you don't need to pass the SOQL in, you can of course hard code the SOQL in the class and just use a GET.

  • 1
    Custom Apex REST is definitely the way to go. And then you can also create a custom data structure as an Apex class and return that as you data type. So you can combine whatever information you need.
    – joshbirk
    Mar 5 '14 at 20:36

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.