You are not logged in.
Hi,
I get server error message (501) Not Implemented when using API to create an upload from Asp.Net.
The API works fine from Swagger UI.
curl -X PUT "https://chorus/rest/v1/uploads" -H "accept: application/json" -H "X-Chorus-Session: xD08seWiOWp8kmo7ySmkri8dPnDmYMsz" -H "Content-Type: application/json" -d "{ \"destinationFolderId\": \"cd0cb9d4-795d-4753-9aba-275e22c256b2\"}"
Asp.Net code
============================================================
protected void Button2_Click(object sender, EventArgs e)
{
string url = "https://chorus/rest/v1/uploads";
string data = "{ \"destinationFolderId\": \"cd0cb9d4-795d-4753-9aba-275e22c256b2\"}";
string[] headers = { "accept:application/json", "X-Chorus-Session:xD08seWiOWp8kmo7ySmkri8dPnDmYMsz","Content-Type:application/json" };
string strResponse = myclass.REST_API_Request(url, data, headers);
myclass = null;
}
public string REST_API_Request(string url, string data, string[] headers )
{
WebRequest myReq = WebRequest.Create(url);
//Headers
foreach (string h in headers)
{
string key = h.Split(':')[0];
string val = h.Split(':')[1];
myReq.Headers.Add(key, val);
}
//data
if (data != "")
{
myReq.Method = "POST";
myReq.ContentLength = data.Length;
myReq.ContentType = "application/json; charset=UTF-8";
UTF8Encoding enc = new UTF8Encoding();
using (Stream ds = myReq.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
}
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
return content;
}
=======================================================
Thanks,
Cham
Offline