【问题标题】:Making LinkedIn API request using Hammock .net web library使用 Hammock .net 网络库发出 LinkedIn API 请求
【发布时间】:2011-04-11 16:15:52
【问题描述】:

我正在使用 C# 和 Hammock 库与 LinkedIn API 进行一些集成。

我一直在尝试使用消息传递 API...我收到一条错误消息“无法解析邮箱项目文档:错误:null 后文件意外结束”。

我不知道 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>

提前致谢。

【问题讨论】:

    标签: c# api rest linkedin


    【解决方案1】:

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

    【讨论】:

    • 嗯,这是我的疑问之一......我应该将内容添加到客户端还是请求?现在我在客户端做。
    • 无所谓;这只是一个优先事项,因为它们都继承自同一个基类。这样您就可以在客户端中设置“默认值”,但在请求中覆盖它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    • 2017-06-09
    • 1970-01-01
    • 2013-10-26
    • 1970-01-01
    相关资源
    最近更新 更多