2

I want to share to LinkedIn on behalf of those users who are already authenticated by my application. But getting HTTP 400 status code.

Here is my code

    Document doc = DocumentHelper.createDocument();
    Element share = doc.addElement("share");
    share.addElement("comment").addText("Guess who is testing the LinkedIn REST APIs");
    Element content = share.addElement("content");
    content.addElement("title").addText("A title for your share");
    content.addElement("submitted-url").addText("http://developer.linkedin.com");
    share.addElement("visibility").addElement("code").addText("anyone");
    String access_token = "XXXXXXXXXXXXXXXXXXXXXX";

    List <NameValuePair> nvps = new ArrayList <NameValuePair>();
    nvps.add(new BasicNameValuePair("text/xml", doc.asXML()));

    URI uri = new URIBuilder().setScheme("https")
            .setHost("api.linkedin.com")
            .setPath("/v1/people/~/shares")
            .build();

    DefaultHttpClient client2 = new DefaultHttpClient();
    HttpPost post = new HttpPost(uri);        
    post.setHeader("Authorization", "Bearer "+access_token);        
    post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));        
    HttpResponse profileResponse = client2.execute(post);

Please help. Any help would be greatly appreciated.

Andy
  • 63
  • 5
  • Well, Are you partnered with Linkedin? I am pretty sure they now only allow specific companies to use their API. http://techcrunch.com/2015/02/12/linkedin-battens-down-the-hatches-on-api-use-limiting-full-access-to-partners/#.phytfk:3Xoe – Hozikimaru Jun 05 '15 at 14:46
  • @SurgeonofDeath I can fetch user details from LinkedIn using API, for those users who allows my application. But, here I think I am doing something wrong, can you please point out what I am doing wrong! – Andy Jun 08 '15 at 06:30

0 Answers0