Sample Apex Code for call out with oAuth token

Sample Code:

        HTTP h = new HTTP();
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('<Enter Endpoint URL>');
        req.setMethod('GET');
        req.setHeader('Authorization', 'Bearer <Enter Token>');
        HTTPResponse res = h.send(req);            
        String str = res.getBody();

Cheers!!!

No comments:

Post a Comment