function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael SMichael S 

Howto: Use SOAP to get report data in XML?

I am trying to figure out how to get the data that I see in the reports using SOAP.  Specifically I want to get the data returned from the "Opportunity Pipeline" report.  What is the procedure that I should follow to get the data from a named report?
adamgadamg
Its a bit of a hack, but one technique I've used in the past is to grab the report as a CSV (using the export to Excel URL) and then transform it to XML.  The URL structure of report export is static, so its fairly safe it use programatically.
Michael SMichael S
How can that be done via the sforce API?
adamgadamg
No, you'd  be grabbing the contents of the URL directly, not via the API.  This should be pretty straightforward (ie open a HTTP connection to the URL in the language of your choice, and just stream-in the contents.)

Message Edited by adamg on 10-10-2003 10:30 AM

Ron HessRon Hess

I also have attempted this, but have not figured it out yet.

To access the report URL I need to be authenticated as a user, so, can I use the session ID I get back from an API Login to pass inside a cokie in the user-agent which then attempts to open the report URL directly ?

thanks,

Ron Hess

adamgadamg
Yes, you can either set the cookie in the HTTP headers or pass it in the query string (ie ?sessionid=xyz)
Ron HessRon Hess
ok, i got this to work, thanks for the tip!
SergeantAgniSergeantAgni

I am attempting to use this technique, first just to list the reports available via the reports URL: https://na1.salesforce.com/rpt/rptlist.jsp and adding the sessionid parameter in a query string added to this as suggested by adamg in this thread.  I get an HTTP 500 response code.  I'm probably missing something obvious.  If so, please let me know.

Details:

I'm using Apache Axis to access SForce API version 2.0.  I am getting the session id and the API endpoint and using them to construct the URL to get the report listing.  I'm using java.net.URL to access the URL.  Here is the error output:

sessionid: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
endpoint:  http://na1-api.salesforce.com/servlet/servlet.SoapApi
URL: http://na1-api.salesforce.com/rpt/rptlist.jsp?sessionid="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

- IOException: Server returned HTTP response code: 500 for URL: http://na1-api.salesforce.com/rpt/rptlist.jsp?sessionid="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

 

Message Edited by SergeantAgni on 11-17-2003 06:12 PM

DevAngelDevAngel

Hi SergeantAgni,

First, I think if you remove the "-api" from the url you will have better luck.  If you notice on your post, the first sentence you have https://na1.salesforce.com..... and later the error message says http://na1-api.salesforce.com......

Second, this approach, although better than nothing is rife with risk and peril.  What happens when on November 21st we change our url scheme?  This is a common occurance.  We cannot guarantee, that your urls will work from release to release and then you have to go do the coding all over again and all the customers who might have your software all break at once and pain and agony and gnashing of teeth.

Use this technique at your own risk!

Reports are not exposed in the api, not even a list of available reports.  I would suggest that for reporting, you handle it on the client.  That is to say, gather the criteria required and pull the data then do any kind of rollups or aggregates on the client.  Maybe in a future release we will better support Reports as an object through the API.