gpt4 book ai didi

c# - 使用 Hammock .net 网络库发出 LinkedIn API 请求

转载 作者:太空宇宙 更新时间:2023-11-03 16:46:54 27 4
gpt4 key购买 nike

我正在使用 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>

提前致谢。

最佳答案

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

关于c# - 使用 Hammock .net 网络库发出 LinkedIn API 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5624295/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com