Sample Apex Code for call out with oAuth token

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();

Leave a Reply