使用 Hammock .net Web 库发出 LinkedIn API 请求
我正在使用 C# 和 Hammock 库与 LinkedIn API 进行一些集成。
我在尝试使用消息 API 时遇到了困难...我收到一条错误消息“无法解析邮箱项目文档:错误:空值后出现意外的文件结尾”。
看来 POST 内容会变空,我不知道...
这是我的代码:
RestClient client = new RestClient();
client.Authority = "http://api.linkedin.com/v1";
client.Credentials = credentials;
//client.Method = WebMethod.Post;
byte[] msg = Encoding.Default.GetBytes(doc.OuterXml);
client.AddPostContent(msg);
RestRequest request = new RestRequest();
request.Path = "/people/~/mailbox";
request.Method = WebMethod.Post;
//request.AddPostContent(msg);
RestResponse response = client.Request(request);
我的 xml(位于 msg 变量中)是:
<?xml version="1.0" encoding="UTF-8"?>
<mailbox-item>
<recipients>
<recipient>
<person path="/people/~" />
</recipient>
</recipients>
<subject>teste</subject>
<body>teste</body>
</mailbox-item>
提前致谢。
I'm doing some integration with LinkedIn APIs using C# and the Hammock libray.
I'm stuck trying to use the messaging API... I get an error saying "Couldn't parse mailbox-item document: error: Unexpected end of file after null".
It seams that the POST content is going empty I don't know...
Here's my code:
RestClient client = new RestClient();
client.Authority = "http://api.linkedin.com/v1";
client.Credentials = credentials;
//client.Method = WebMethod.Post;
byte[] msg = Encoding.Default.GetBytes(doc.OuterXml);
client.AddPostContent(msg);
RestRequest request = new RestRequest();
request.Path = "/people/~/mailbox";
request.Method = WebMethod.Post;
//request.AddPostContent(msg);
RestResponse response = client.Request(request);
My xml (that goes in msg variable) is:
<?xml version="1.0" encoding="UTF-8"?>
<mailbox-item>
<recipients>
<recipient>
<person path="/people/~" />
</recipient>
</recipients>
<subject>teste</subject>
<body>teste</body>
</mailbox-item>
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的代码中,添加 POST 内容的行已被注释掉!
In your code, the line that adds the POST content is commented out!