Search code examples
meteoroauth-2.0linkedin-api

share on linkedin returns "Can not parse JSON share document"


I am trying to share a post on linkedin.

I managed to log in and get returned an id and an accessToken but when I follow the REST APIs way of sharing an update I keep getting:

Error: failed [400] {
  "errorCode": 0,
  "message": "Can not parse JSON share document.\nRequest body:\n\nError:\nnull",
  "requestId": "NWGE7D4LSW",
  "status": 400,
  "timestamp": 1451699447711
}

My http POST looks like this:

HTTP.post('https://api.linkedin.com/v1/people/~/shares?format=json&oauth2_access_token=' + accessToken, {
            'headers': {
              'Content-Type': "application/json",
              'x-li-format': "json"
            },
            'comment': "test!",
            'visibility': {
              'code': "anyone"
            }
          });

Solution

  • this worked:

          HTTP.post('https://api.linkedin.com/v1/people/~/shares?format=json&oauth2_access_token=' + Meteor.user().services.linkedin.accessToken, {
            headers: {
              "Content-Type": "application/json",
              "x-li-format": "json"
            },
            data: {
              comment: "testing",
              visibility: {
                code: "anyone"
              }
            }
          });