+ Start a Discussion
mayank_friend52mayank_friend52 

Unable to like a linkedin company update through Linkedin Api?

Hello,

I am unable to 'like' a linkedin company update post through Linkedin Like API.

It is throwing an error, 'Status=Method Not Allowed, StatusCode=405',\

I am using this Code as shown below:

        Http h = new Http();
        String postParam ='';
        String method = 'PUT';
        string body1 ='<?xml version="1.0" encoding="UTF-8"?><is-liked>true</is-liked>';
        string sharequery='http://api.linkedin.com/v1/people/~/network/updates/key=UPDATE-c1756-5902360166031974400/is-liked';
        HttpRequest sharequery_req= new HttpRequest();  
        sharequery_req.setMethod(method);
        sharequery_req.setBody(body);
        sharequery_req.setEndpoint(sharequery.replace('~','%7E'));
        sharequery_req.setHeader('Content-Type', 'text/xml'); //header setting for HttpRequest object
        HttpResponse share_response= h.send(sharequery_req);
        integer statuscode=share_response.getstatuscode();

Please suggets some way to achieve this.

Thanks,
Mayank
Martijn SchwarzerMartijn Schwarzer
Hi Mayank,

It seems that the method "PUT" is not allowed. Try changing it to "POST".

Regards,
Martijn Schwärzer