function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sandeep@Salesforcesandeep@Salesforce 

Getting Error Method Not Allowed while integrating with LinkedIn


Hi, 
I am integrating Salesforce with Linked in and getting below error while accessing linkedIn apis using accessToken. I am sure that access token is valid.
Here is my code 
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        string endPointValue = 'https://api.linkedin.com/v1/people/';
         //'https://api.linkedin.com/v1/people/~:(id,num-connections,picture-url)?format=json';//'https://api.linkedin.com/v1/people/~/shares?format=json';
        req.setendpoint(endPointValue );
        string bodyRequest = '{ "comment": "Check out developer.linkedin.com! http://linkd.in/1FC2PyG", "visibility": {"code": "anyone"}}';
        req.setBody(bodyRequest);     
        System.debug(bodyRequest);
        req.setHeader('Authorization', 'Bearer ' + accessToken);
        req.setHeader('Content-length', string.ValueOf(bodyRequest.length())); 
        req.setHeader('Content-Type', 'application/json; charset=UTF-8');
        req.setMethod('GET');
        req.setTimeout(10000);
        HttpResponse res = h.send(req); 
        System.debug('===='+res.getBody());
Getting below Error: 
16:48:22.131 (1131126887)|CALLOUT_REQUEST|[46]|System.HttpRequest[Endpoint=https://api.linkedin.com/v1/people/, Method=GET] 16:48:22.958 (1958244094)|CALLOUT_RESPONSE|[46]|System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
 
Amit Chaudhary 8Amit Chaudhary 8
You are passing request body in get method. Please try post or put method.