Trialhead Apex REST Callouts challenge https://developer.salesforce.com/trailhead/apex_integration_services/apex_integration_rest_callouts
Hi i am very new to salesforce and has statred learning through Trialhead. I am in the REST callouts section. I started it but i don't know how to get the response. i am not sure if i am going about this right. This is my first time even seeing a http service. please any help or guidance would be appreciated. i have pasted my code here .. I get an error that an object cannot be assigned to a string. if i change the type of result to object , the error goes away.I am not sure how to convert it back to a string.
public class AnimalLocator {
public static String getAnimalNameById(Integer id){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/:id');
request.setMethod('GET');
HttpResponse response = http.send(request);
// check the response
if (response.getStatusCode() == 200)
{
String result = JSON.deserializeUntyped(response.getBody());
}//end of if
return null;
}//end of method
}//end of class