Challenge Not yet complete... There was an unexpected error which is preventing this assessment check from completing: System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint . Please help:
Authorize both of these endpoint URLs by following these steps.
1.From Setup, enter Remote Site Settings in the Quick Find box, then click Remote Site Settings. 2.Click New Remote Site. 3.For the remote site name, enter animals_http. 4.For the remote site URL, enter https://th-apex-http-callout.herokuapp.com. This URL authorizes all subfolders for the endpoint, like https://th-apex-http-callout.herokuapp.com/path1 and https://th-apex-http-callout.herokuapp.com/path2. 5.For the description, enter Trailhead animal service: HTTP. 6.Click Save & New. 7.For the second remote site name, enter animals_soap. 8.For the remote site URL, enter https://th-apex-soap-service.herokuapp.com. 9.For the description, enter Trailhead animal service: SOAP. 10.Click Save.
for code reference you can verify from the below working code.
AnimalLocator
public class AnimalLocator{
public static string getAnimalNameById(Integer id) {
Http http = new Http();
HttpRequest hreq = new HttpRequest();
hreq.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+id);
hreq.setMethod('GET');
HttpResponse res = http.send(hreq);
Map<String,Object> animals = new Map<String,Object>();
if (res.getStatusCode() == 200) {
Map<String,Object> results = (Map<String,Object>)JSON.deserializeUntyped(res.getBody());
animals = (Map<String,Object>)results.get('animal');
}
else{System.debug('The status code returned was not expected: ' + res.getStatusCode() + ' ' + res.getStatus());}
return (string)animals.get('name');
}
}
I think the endpoint which u configured in remote site setting is incorrect.Try to check the url by going to Setup--> Security--> Remote Site Settings.
Authorize both of these endpoint URLs by following these steps.
1.From Setup, enter Remote Site Settings in the Quick Find box, then click Remote Site Settings. 2.Click New Remote Site. 3.For the remote site name, enter animals_http. 4.For the remote site URL, enter https://th-apex-http-callout.herokuapp.com. This URL authorizes all subfolders for the endpoint, like https://th-apex-http-callout.herokuapp.com/path1 and https://th-apex-http-callout.herokuapp.com/path2. 5.For the description, enter Trailhead animal service: HTTP. 6.Click Save & New. 7.For the second remote site name, enter animals_soap. 8.For the remote site URL, enter https://th-apex-soap-service.herokuapp.com. 9.For the description, enter Trailhead animal service: SOAP. 10.Click Save.
for code reference you can verify from the below working code.
AnimalLocator
public class AnimalLocator{
public static string getAnimalNameById(Integer id) {
Http http = new Http();
HttpRequest hreq = new HttpRequest();
hreq.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+id);
hreq.setMethod('GET');
HttpResponse res = http.send(hreq);
Map<String,Object> animals = new Map<String,Object>();
if (res.getStatusCode() == 200) {
Map<String,Object> results = (Map<String,Object>)JSON.deserializeUntyped(res.getBody());
animals = (Map<String,Object>)results.get('animal');
}
else{System.debug('The status code returned was not expected: ' + res.getStatusCode() + ' ' + res.getStatus());}
return (string)animals.get('name');
}
}
First You have to perform below steps in your trailhead Org where you are checking this module.
https://th-apex-http-callout.herokuapp.com
https://th-apex-soap-service.herokuapp.com
Authorize both of these endpoint URLs by following these steps.
1.From Setup, enter Remote Site Settings in the Quick Find box, then click Remote Site Settings.
2.Click New Remote Site.
3.For the remote site name, enter animals_http.
4.For the remote site URL, enter https://th-apex-http-callout.herokuapp.com. This URL authorizes all subfolders for the endpoint, like https://th-apex-http-callout.herokuapp.com/path1 and https://th-apex-http-callout.herokuapp.com/path2.
5.For the description, enter Trailhead animal service: HTTP.
6.Click Save & New.
7.For the second remote site name, enter animals_soap.
8.For the remote site URL, enter https://th-apex-soap-service.herokuapp.com.
9.For the description, enter Trailhead animal service: SOAP.
10.Click Save.
for code reference you can verify from the below working code.
AnimalLocator
AnimalLocatorTest
AnimalLocatorMock
Please let me know if this help you !!
Thanks !!
All Answers
I think the endpoint which u configured in remote site setting is incorrect.Try to check the url by going to Setup--> Security--> Remote Site Settings.
Best Regards,
Manasa.G
First You have to perform below steps in your trailhead Org where you are checking this module.
https://th-apex-http-callout.herokuapp.com
https://th-apex-soap-service.herokuapp.com
Authorize both of these endpoint URLs by following these steps.
1.From Setup, enter Remote Site Settings in the Quick Find box, then click Remote Site Settings.
2.Click New Remote Site.
3.For the remote site name, enter animals_http.
4.For the remote site URL, enter https://th-apex-http-callout.herokuapp.com. This URL authorizes all subfolders for the endpoint, like https://th-apex-http-callout.herokuapp.com/path1 and https://th-apex-http-callout.herokuapp.com/path2.
5.For the description, enter Trailhead animal service: HTTP.
6.Click Save & New.
7.For the second remote site name, enter animals_soap.
8.For the remote site URL, enter https://th-apex-soap-service.herokuapp.com.
9.For the description, enter Trailhead animal service: SOAP.
10.Click Save.
for code reference you can verify from the below working code.
AnimalLocator
AnimalLocatorTest
AnimalLocatorMock
Please let me know if this help you !!
Thanks !!