无法使用Jive REST API发布共享-收到400个错误请求
本文关键字:共享 收到 请求 错误 400个 布共享 Jive REST API | 更新日期: 2023-09-27 18:08:55
我正在尝试使用c#在。net中使用/Shares REST API在Jive上发布一个共享。然而,我无法做到这一点,并得到以下错误:
"远程服务器返回一个错误:(400)错误请求。"
下面是我写的代码:
string response = string.Empty;
using(WebClient client = new WebClient())
{
string strJiveShareURL = "https://<JiveURL>";
strJiveShareURL += "/api/core/v3/shares";
var SharedJSON = new AddShareJSON
{
participants = new string[] {"https://<JiveURL>/api/core/v3/people/{username}" },
shared = "https://<<Content URL to be shared>>",
content= new Content
{
type = "text/html",
text = "This is a test share from SharePoint to Jive"
}
};
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string shareJSON = serializer.Serialize(SharedJSON);
Console.WriteLine("Setting Credentials:");
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("UID:PWD"));
client.Headers[HttpRequestHeader.Authorization]= "Basic " + credentials;
client.Headers[HttpRequestHeader.Accept] = "application/json";
client.Headers[HttpRequestHeader.ContentType] = "application/json";
//BypassCertificateError();
response = client.UploadString(strJiveShareURL, "POST", shareJSON);
Console.WriteLine("Response:" + response);
Console.ReadLine();
}
,下面是为发布共享而创建的JSON:
{
"content": {
"type":"text/html",
"text":"This is a test share from SharePoint to Jive"
},
"participants": ["https://<<Jive URL>>/api/core/v3/people/<<username>>"],
"Shared":"https://<<URL of the Content To be Shared>>"
}
如果我做错了什么,请告诉我。
我自己弄清楚了,我得到了错误,因为我传递了一个无效的URI对象到共享REST端点的共享参数。共享参数需要
形式的内容URI。http://[[JiveURL]]/api/核心/v3/内容/[[版权id]有些过火]
早些时候,我试图传递外部的url到Jive,导致错误的请求。