[SalesForce] how to return the report results from a SOQL query using the REST Api in Salesforce Mobile SDK for iOS

I am using the Salesforce Mobile SDK 2.0 to build a connected Salesforce Native iOS app, I would like to be able to run reports programatically using the SFRestRequest method (or some other method?), can you show code examples of how this might be done? Secondly, is it also possible to send filter parameters through to the report as well, such as account id? My code snippet in its current state (I am able:

SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:@"SELECT id, Image_Filename__c FROM product2 WHERE (Group__c !='Discontinued') ORDER BY name ASC"];
[[SFRestAPI sharedInstance] send:request delegate:self];

Best Answer

so goodnews/badnews:

Good news, I can tell you how to do this.

Bad news, you're going to write your own objective-c methods because the Salesforce Mobile IOS Sdk only wraps the sObject api.

Ideally, you'd replicate the architecture of the sfRestRequest and SFRestApi, setting it up to hit the resource that Andrew Fawcett mentioned above to retrieve your data as json.

Specifically, your custom cloned sfRestRequest class needs to set the resource url, and the SFRestApi needs to have a method to call the analytics api with your new sfRestRequest cloned class.

Once you've written obj-c methods to hit: /services/data/<latest API version>/analytics/reports/<report ID> with your ReportID, you'll be returned a JSON payload.

That json payload can be parsed as normal!

Related Topic