C# 无法使用Jive REST API发布共享-获取400错误请求错误

C# 无法使用Jive REST API发布共享-获取400错误请求错误,c#,json,rest,jive,C#,Json,Rest,Jive,我正在尝试使用C#在.net中使用/Shares REST API在Jive上发布共享。但是,我无法执行此操作,并出现以下错误: “远程服务器返回错误:(400)请求错误。” 以下是我编写的代码: string response = string.Empty; using(WebClient client = new WebClient()) { string strJiveShareURL = "https://<JiveURL>"; strJiv

我正在尝试使用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();



}
string响应=string.Empty;
使用(WebClient=newWebClient())
{
字符串strJiveShareURL=“https://”;
strJiveShareURL+=“/api/core/v3/shares”;
var SharedJSON=new addsharedjson
{
参与者=新字符串[]{”https:///api/core/v3/people/{username}“},
shared=“https://”,
内容=新内容
{
type=“text/html”,
text=“这是从SharePoint到Jive的测试共享”
}
}; 
var serializer=new System.Web.Script.Serialization.JavaScriptSerializer();
字符串shareJSON=serializer.Serialize(SharedJSON);
Console.WriteLine(“设置凭据:”);
字符串凭据=Convert.ToBase64String(Encoding.ASCII.GetBytes(“UID:PWD”);
client.Headers[HttpRequestHeader.Authorization]=“Basic”+凭证;
client.Headers[HttpRequestHeader.Accept]=“application/json”;
client.Headers[HttpRequestHeader.ContentType]=“application/json”;
//绕过证书错误();
response=client.UploadString(strJiveShareURL,“POST”,shareJSON);
Console.WriteLine(“响应:+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>>"

}
{
“内容”:{
“类型”:“文本/html”,
“文本”:“这是从SharePoint到Jive的测试共享”
},
“与会者”:[”https:///api/core/v3/people/"],
“共享”:“https://”
}

请告诉我是否有任何操作不正确的地方。

我自己发现了这一点,因为我将一个无效的URI对象传递给Share REST端点的共享参数。共享参数需要一个内容URI,格式为

早些时候,我试图将URL传递到Jive外部,导致错误的请求错误