How to use Named Credentials to simplify your Apex


public class GithubOAuthCallout {
   
    public static void callGitHub(){
        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:GitHub_OAuth/users/Coding-With-The-Force/repos');
        req.setMethod('GET');
        req.setHeader('Accept', 'application/json');
        req.setHeader('Content-Type', 'application/json');
        Http http = new Http();
        HTTPResponse res = http.send(req);
        if (res.getStatusCode() == 200) {
System.debug('Response: ' + res.getBody()); } else { System.debug('Error: '+ res.getStatusCode() + ' - ' + res.getBody()); }
    }
}

 

Comments

Popular posts from this blog

My Trigger Scenario's

Configure types Of Products in CPQ and Revenue Cloud ?

Steps for Calculate Derived Pricing in RCA ?