Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
// Deserialize the JSON string into collections of primitive data types.
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
// Cast the values in the 'animals' key as a list
List<Object> animals = (List<Object>) results.get('animals');
System.debug('Received the following animals:');
for (Object animal: animals) {
System.debug(animal);
}
}
Use the below link for the deep knowledge og http callout.
1) https://trailhead.salesforce.com/en/modules/apex_integration_services/units/apex_integration_rest_callouts
2) https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts
3) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm
for more help please send your question on the same.
Thanks & Regards
David Hales(1021)
If you want to learn about HTTP Callout in salesforce i will recomment you to check below trailhead module
1) Apex Integration Services (https://trailhead.salesforce.com/modules/apex_integration_services)
Sample code for HTTP callout
Please check below post as well i hope that will help you
1) http://amitsalesforce.blogspot.com/2017/01/learn-rest-api-in-salesforce-how-to.html
Let us know if this will help you