+ Start a Discussion
Arpit Patel 8Arpit Patel 8 

Error while calling REST Analytics API in Apex


I'm trying to call the Analytics REST API in my Apex code. I'm getting an Read Time Out exception. Can someone look at it and let me know what can be the issue.

The code snippet and debug log is given below:

   HttpRequest req = new HttpRequest();
  //Set HTTPRequest header properties

  req.setHeader('content-type', 'application/json.');
  req.setEndpoint( URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v29.0/analytics/reports/00OQ0000000epc5');
  req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());

  Http http = new Http();
   try {
        //Execute web service call here    
        HTTPResponse res = http.send(req); 

} catch(System.CalloutException e) {

Debug Log:

21:27:35.060 (60501282)|CALLOUT_REQUEST|[28]|System.HttpRequest[Endpoint=https://test.salesforce.com/services/data/v29.0/analytics/reports/00OQ0000000epc5, Method=GET]
21:27:45.079 (10079369700)|EXCEPTION_THROWN|[28]|System.CalloutException: Read timed out


James LoghryJames Loghry
Have you added test.salesforce.com to your Remote Site Settings? (Setup->Security Controls->Remote Site Settings)

Also, what happens when you:
  1. Change the api version to v31.0?
  2. Run the same URL through REST console in Chrome, or some other REST testing application?
Prachi Gadewar SFDCPrachi Gadewar SFDC
@Arpit Patel 8

Did you find any solution to solve that exception comes while calling the REST analystics? I have same kind of requirement to do. Help wold appriciated Thanks!!!!