使用 Hammock .net Web 库发出 LinkedIn API 请求

发布于 2024-10-31 18:12:15 字数 969 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情未る 2024-11-07 18:12:15

在您的代码中,添加 POST 内容的行已被注释掉!

In your code, the line that adds the POST content is commented out!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文