使用Restsharp在LinkedIn上分享

时间:2013-03-17 20:14:26

标签: linkedin restsharp

我有困难使用restsharp分享使用linkedin的工作。这是我的代码:

    var shareMsg = new
    {
        comment = "Testing out the LinkedIn Share API with JSON",
        content = new
        {
            title = "Test post to LinkedIn",
            submitted_url = "http://www.somewebsite.com",
            submitted_image_url = "http://www.somewebsite.com/image.png"
        },
        visibility = new
        {
            code = "anyone"
        }
    };

    RestClient rc = new RestClient(LinkedInAppInfo.LinkedInBaseApiUrl);
    RestRequest request = new RestRequest(LinkedInAppInfo.SharePostPath, Method.POST);
    request.RequestFormat = DataFormat.Json;
    request.AddParameter("format", "json");
    request.AddBody(shareMsg);
    request.AddParameter("oauth2_access_token", accessToken, ParameterType.GetOrPost);

    RestResponse restResponse = (RestResponse)rc.Execute(request);
    ResponseStatus responseStatus = restResponse.ResponseStatus;

我得到的结果是:

{
  "errorCode": 0,
  "message": "Couldn't parse share document: error: Unexpected end of file after null",
  "requestId": "06ZU78FUNW",
  "status": 400,
  "timestamp": 1363551953855
}

对我做错了什么的想法?

0 个答案:

没有答案