在linkedin上分享返回“无法解析JSON共享文档”

时间:2015-12-28 17:35:24

标签: meteor oauth-2.0 linkedin

我正在尝试分享关于linkedin的帖子。

我设法登录并返回了idaccessToken,但当我按照sharing an update的方式使用REST API时,我一直得到:

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

我的http POST看起来像这样:

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"
            }
          });

1 个答案:

答案 0 :(得分:0)

这有效:

      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"
          }
        }
      });