I have written this code : public class AnimalLocator {
public static String getAnimalNameById(Integer i) {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals'+i);
request.setMethod('GET');
HttpResponse response = http.send(request);
//if the request is successful, parse the JSON response
if(response.getStatusCode()==200){
Map<String,Object> result = (Map<String,Object>)JSON.deserializeUntyped(response.getBody());
Map<String,Object> animal = (Map<String, Object>) result.get('animal');
return string.valueOf(animal.get('name'));
}else{
return null;
}
}
}
and I am getting this error
Hi @Sravya Kummari ,
whenever we work with REST API we need to allow salesforce to hit that API, for that the endpoint URL should be added in remote site settings;
go to Setup -> Remote site settings:- add a new remote site setting name it anything but URL should be https://th-apex-http-callout.herokuapp.com . then you can check the challenge
https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000BqpSCSAZ