You need to sign in to do that
Don't have an account?
Jamal Rida
Challenge Not yet complete... here's what's wrong: Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById', is public and static, accepts an Integer and returns a String.
Hi All,
I'm trying to complete a challenge related to Apex Rest, but i'm facing a problem when validating it, it's kind of facing an error in the method definition even if i've checked it, below is a snippet of the code and the error message i get from the trailhead :
Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById', is public and static, accepts an Integer and returns a String.
I'm trying to complete a challenge related to Apex Rest, but i'm facing a problem when validating it, it's kind of facing an error in the method definition even if i've checked it, below is a snippet of the code and the error message i get from the trailhead :
public class AnimalLocator { public static JSON2Apex animalWrapper; public static String getAnimalNameById(Integer animalId){ Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+animalId+':Id'); request.setMethod('GET'); System.debug('###request : '+request); HttpResponse response = http.send(request); System.debug('###response : '+response.getBody() ); // If the request is successful, parse the JSON response. if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. animalWrapper = new JSON2Apex(); System.debug('Received 1:'+(JSON2Apex)System.JSON.deserializeStrict(response.getBody(), JSON2Apex.Class)); animalWrapper = (JSON2Apex)System.JSON.deserializeStrict(response.getBody(), JSON2Apex.class); System.debug('Received the following animals:'+animalWrapper); System.debug('###myAnimal : '+animalWrapper.animal.name); // return animalWrapper.animal.name; } return animalWrapper.animal.name; } }Challenge Not yet complete... here's what's wrong:
Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById', is public and static, accepts an Integer and returns a String.