0

I want to get the data from third party app. When i try to get the data through HTTP get request getting System.CalloutException: Read Time out error.

I have checked the endpoint url on browser and can see the data.

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://rt4.marcura.com/REST/1.0/search/ticket/?user=salesforce&pass=salesforcepass&query=CX::Team1&format=s&fields=Subject,Queue,CF.{Account%20Name}');
request.setMethod('GET');
request.setTimeout(12000);
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
    // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
    // Cast the values in the 'tickets' key as a list
    List<Object> tickets = (List<Object>) results.get('tickets');
    System.debug('Received the following tickets:');
    for (Object ticket: tickets) {
        System.debug(ticket);
    }
}

Kindly advise.

  • Did you try increasing the time out value in setTimeout method at line 5? – venky Jun 22 '17 at 5:57
  • yes, It's a maximum 120 sec buy still the same error. – Russel baker 1 Jun 22 '17 at 5:58
  • The read time out error is stating that the method did not return an HTTPResponse within the timeout interval. Can you debug the web service to see if the message was received? How long it took? You can configure the timeout too. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – venky Jun 22 '17 at 6:03
  • Have you tried to access that endpoint with postman or any other client? – Javier García Manzano Jun 22 '17 at 6:46
  • Yes, I have tried endpoint with ARC goggle chrome extension and it's working fine. I tried to debug the code and getting status error 504 bad getaway. – Russel baker 1 Jun 22 '17 at 8:12
1

Issue resolved. It was network issue and solved by white list the Salesforce IP addresses range.

| improve this answer | |

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.