I am trying to make a callout to an open public api. When I tested it on Postman, it is giving me the expected response. But when I tried it on the Apex class, the response is giving me the following output.
I have configured 'the remote site settings' for the endpoint. Anyone knows what can be the problem?
Here is my code:
public class retrieveStocks {
public static HttpResponse retrieveStocks() {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://tradestie.com/api/v1/apps/reddit');
request.setHeader('Content-Type', 'application/json');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if(response.getStatusCode() == 200) {
// Deserializes the JSON string into collections of primitive data types.
system.debug(response.getBody());
}
system.debug(response.getBody());
return response;
}
}
As always, thank you in advance!!!!!