In short how to do an apex callout from Class..
Apex class:
*******************************************
global class with sharing ApexCallout{
public void callout()
{
//Construct a HTTP Request
HttpRequest req = new HttpRequest() ;
string strUrl=’**********Place your Remote Site Address here**********”;
//Before making this callout, you need to add Remote site address in the Remote Site Settings of your Organization..
//Setting Endpoint URL to HTTP request
req.setEndpoint(strUrl);
//Set the request type
req.setMethod(‘GET’);
//HTTP object creation
Http http = new Http();
//Sending the Req throgh HTTPResponse object.
HTTPResponse res = http.send(req);
//System.debug(res.getBody());
//System.debug(res.getStatus());
}
}
If you need to pass some parameters in the method, you can do it..
by changing the method to method with arguments.
You can call this method from trigger also..

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *

*