8

I'm looking for examples of how to query the salesforce rest api, to get the values from these reports.

enter image description here

Reading this site, gives an example, but not much explanation.

curl https://na1.salesforce.com/services/data/v20.0/sobjects/Account/ -H "Authorization: Bearer token"

I'm looking for links, resources, or examples of how to query a report.

Update
My end goal is to receive json looking something like this:

{
     "reports" {
     "newTicketsThisWeek" : 36
     "newTickes120days": 912
     }
}

Update

I have managed to get basic information from the REST api. I am still looking for how to query a report.

curl  -H 'Authorization: Bearer <my sid from session cookie>' -H "X-PrettyPrint:1" https://foo.my.salesforce.com/services/data/v28.0/

{
  "sobjects" : "/services/data/v28.0/sobjects",
  "licensing" : "/services/data/v28.0/licensing",
  "identity" : "https://login.salesforce.com/id/00DE0000000K0eMMAS/005E00000018QfBIAU",
  "connect" : "/services/data/v28.0/connect",
  "search" : "/services/data/v28.0/search",
  "quickActions" : "/services/data/v28.0/quickActions",
  "query" : "/services/data/v28.0/query",
  "knowledgeManagement" : "/services/data/v28.0/knowledgeManagement",
  "tooling" : "/services/data/v28.0/tooling",
  "chatter" : "/services/data/v28.0/chatter",
  "recent" : "/services/data/v28.0/recent"
}

Update

I have found the report in the API, however it does not appear to have any queriable data

salesforcekey = foo
curl -H "Authorization: Bearer $salesforcekey" -H "X-PrettyPrint:1" https://acme.my.salesforce.com/services/data/v28.0/sobjects/report/bar

{
  "attributes" : {
    "type" : "Report",
    "url" : "/services/data/v28.0/sobjects/Report/00OE000000qqqqqqq"
  },
  "Id" : "00OE000000xxxxxx",
  "OwnerId" : "00lE0000000yyyyyyyy",
  "CreatedDate" : "2012-06-26T16:48:20.000+0000",
  "CreatedById" : "005E0000000zzzzzz",
  "LastModifiedDate" : "2012-06-26T21:27:29.000+0000",
  "LastModifiedById" : "005E0000000zzzzzzz",
  "IsDeleted" : false,
  "Name" : "WW Support - Weekly Tickets",
  "Description" : null,
  "DeveloperName" : "WW_Support_Weekly_Tickets",
  "NamespacePrefix" : null,
  "LastRunDate" : "2013-08-12T17:52:14.000+0000",
  "SystemModstamp" : "2013-08-12T17:52:14.000+0000",
  "LastViewedDate" : "2013-08-12T17:58:08.000+0000",
  "LastReferencedDate" : "2013-08-12T17:58:08.000+0000"
}

I have also found out about https://apigee.com/ an excellent website for viewing REST api's

http://wiki.developerforce.com/page/REST_API
http://blogs.developerforce.com/tech-pubs/2011/10/salesforce-apis-what-they-are-when-to-use-them.html
http://wiki.developerforce.com/page/Integration

The end product is to create physical sensors that change depending on the result of these reports.
http://reidcarlberg.com/2014/02/21/philips-hue-raspberry-pi-node-js-salesforce-and-you/

3
  • 3
    Similar to salesforce.stackexchange.com/questions/337/…? – Mike Chale Jul 25 '13 at 17:56
  • 2
    Just out of curiousity, why do you want to query the report, wouldn't be better to directly query to data or what are you planning to do? – PepeFloyd Jul 25 '13 at 21:22
  • @PepeFloyd I've updated the description, I'm hoping to retrieve the values show in the reports, as simple json – spuder Jul 25 '13 at 21:44
9

UPDATE: 1st October 2013. Here is a great post by Pat Patterson on using the Analytics API in Visualforce via JQuery. Using the Salesforce Analytics API on a Visualforce Page.

What your asking about I think is the new Analytics API, this provides access to Salesforce Reports via a REST API. There is a little further on the web about this API at present other than the Summer'13 release notes here, as you can read it's a closed pilot for now. You can try asking via support to be considered for it. In the meantime I suspect there will be more news on it as we move towards Dreamforce!

New Analytics API Docs are here

Well, I guess the first thing to mention here is that Dashboards are now available in the iPhone version of Touch, so now along with your iPad users, iPhone users can also access the dashboards they have permissions to view on their phone. The biggest analytics news with this release is the Analytics API, a programatic means of accessing your report data in Salesforce! This has been released as an invitation only, closed pilot but a full release should be on the way shortly. Build your report using the report builder that everyone is familiar with today and using the Analytics API you will be able to call to that report in code and retrieve a JSON string of the metadata and data to allow you to dynamically build visualisations anywhere in your application. Do you have a favourite Javascript visualisation tool? No worries, this is what the Analytics API is built for.

6

The Analytics API from Salesforce is GA in Winter14 (aka, "now").

http://developer.force.com/releases/release/Winter14/AnalyticsAPI

2
  • Nice! I think it could be useful to include a couple examples of calls that the OP could use to access information from the Analytics API... – Benj Sep 30 '13 at 15:22
  • Yes, fair point. We hope to have very rich samples when we launch this at DF14 next month. – Keith Bigelow Oct 9 '13 at 20:49
3

Take that ID that got from /sobjects/report/bar

"Id" : "00OE000000xxxxxx", <-- that line

And do a GET to /analytics/reports/00OE000000xxxxxx

Optionally you can add ?includeDetails=true to get non-aggregate info.

1
  • ?includeDetails=true is useful for getting the actual data from the report – Edward Moffett Mar 26 '19 at 16:52

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.