You need to sign in to do that
Don't have an account?
Duncan_Stewart
Apex REST Callouts module, 'Unauthorized endpoint' error for Hands-on challenge
I'm getting incrementally closer to completing this challenge (thank you to all who have contributed elsewhere), but I don't see this particular issue having been reported. I've got the AnimalLocator, 'Mock & Test running fine, but hitting this unauthorized endpoint error when I check the challenge:
System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://th-apex-http-callout.herokuapp.com/animals/99
I tried cloning the URL as a new Remote Site with '/animals' (or '/animals/') appended, but it keeps getting truncated back to this ^.
My AnimalLocator class is as follows:
System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://th-apex-http-callout.herokuapp.com/animals/99
I tried cloning the URL as a new Remote Site with '/animals' (or '/animals/') appended, but it keeps getting truncated back to this ^.
My AnimalLocator class is as follows:
public class AnimalLocator { // Use a GET callout to retrieve an animal name public static String getAnimalNameById(Integer animalId) { Integer id = animalId; String result = ''; 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); // If the request is successful, parse the JSON response. if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); System.debug('results = ' + results); // Cast the values in the 'animals' key as a list Map<String, Object> animal = (Map<String, Object>) results.get('animal'); System.debug('Received the following animal:' + animal.get('name')); result = (String)animal.get('name'); } return result; } }
https://th-apex-http-callout.herokuapp.com/animals/99
All Answers
https://th-apex-http-callout.herokuapp.com/animals/99
Have you run your code after setting up the Remote Site? You should have no issues now.