我们在使用HTTP POST请求在linkedin中创建Post时收到HTTP错误400 Bad Request。
示例COde:
public static bool PostLinkedInNetworkUpdate(string accessToken, string title, string submittedUrl = "", string submittedImageUrl = "")
{
var requestUrl = String.Format(linkedinSharesEndPoint, accessToken);
var message = new
{
comment = "Testing out the LinkedIn Share API with JSON",
content = new Dictionary<string, string>
{ { "title", title },
{ "submitted-url", submittedUrl },
{"submitted-image-url" , submittedImageUrl}
},
visibility = new
{
code = "anyone"
}
};
var requestJson = new JavaScriptSerializer().Serialize(message);
var client = new WebClient();
var requestHeaders = new NameValueCollection
{
{ "Content-Type", "application/json" },
{ "x-li-format", "json" },
{"Host", "api.linkedin.com"}
};
client.Headers.Add(requestHeaders);
var responseJson = client.UploadString(requestUrl, "POST", requestJson);
var response = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(responseJson);
return response.ContainsKey("updateKey");
}
}
我们收到错误消息:
var responseJson = client.UploadString(requestUrl, "POST", requestJson);
作为HTTP错误400错误请求。
我们已经使用GET Request测试了代码,该代码正在我的Dev服务器上运行,但是任何POST请求都失败并显示此错误消息。
我们已经使用POSTMAN发出的请求验证了REsponse标头.POSTMAN的响应标头与错误请求响应匹配
我们是否需要在服务器中安装LinkedIn证书?
有没有人有任何建议/意见? 提前致谢