我可以从 LinkedIn 获取所有帖子和评论,但我无法添加帖子评论
我尝试使用 Hammock 和 RestSharp 库仍然出现错误
无法解析消息文档或意外的文件结尾 null 未
or
验证方案`
这是我的代码
protected void Page_Load(object sender, EventArgs e)
{
string xmlContent = "<?xml version='1.0' encoding='UTF-8'?>" + Environment.NewLine +
"<comment>" + Environment.NewLine +
"<text>Check out</text>" + Environment.NewLine +
"</comment>";
byte[] dataBytes = Encoding.Default.GetBytes(xmlContent);
var credentials = new Hammock.Authentication.OAuth.OAuthCredentials
{
Type = OAuthType.AccessToken,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
ConsumerKey = "*******",
ConsumerSecret = "**********",
Token = "********",
TokenSecret = "*************",
Version = "1.0"
};
// Am I declaring the URL in correct format
var client = new Hammock.RestClient() { Authority = "http://api.linkedin.com/v1/posts" };
var request = new Hammock.RestRequest() { Path = "/{post-id}/comments", Method = Hammock.Web.WebMethod.Post, Timeout = new TimeSpan(0, 0, 5), Credentials = credentials };
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
//request.AddParameter("application/json",json);
//client.AddPostContent(dataBytes);
request.AddPostContent(dataBytes);
var response = client.Request(request);
Response.Write(response.Content);
}
我收到以下格式的错误
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<error>
<status>400</status>
<timestamp>1374494502579</timestamp>
<request-id>QM4MYPEKJJ</request-id>
<error-code>0</error-code>
<message>Couldn't parse message document: error: Unexpected end of file after null</message>\n</error>