Please find below the code I am using:
Http http = new Http();
HttpRequest request = new HttpRequest();
String url='http://abc:8090/part/abc/abc/';
request.setEndpoint(url);
request.setMethod('GET');
HttpResponse response = http.send(request);
System.debug('Response:'+response);
Http http = new Http();
HttpRequest request = new HttpRequest();
String url='http://abc:8090/part/abc/abc/';
request.setEndpoint(url);
request.setMethod('GET');
HttpResponse response = http.send(request);
System.debug('Response:'+response);
// 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 'animals' key as a list
List<Object> dataErrors = (List<Object>) results.get('dataErrors');
System.debug('Received the following animals:'+dataErrors);
}
I I am able to access the url in the browser and I have added the base url in the Custom site settings too. But the above code does not call the web service. The reponse I get is
Response:System.HttpResponse[Status=Service Unavailable, StatusCode=503]
Response:System.HttpResponse[Status=Service Unavailable,
StatusCode=503]
And when I change the url to 'https://th-apex-http-callout.herokuapp.com/animals' It works perfectly well.
Could anyone please help me if there is anything wrong with the url?