2014-07-11 58 views
0
response = requests.patch("https://<manageraddress>/api/admin/configuration/v1/conference/1/", auth=('<user1>', '<password1>'), verify=False, data=json.dumps({'pin': '1234'}) https://tsmgr.tsecurevideo.com/api/admin/configuration/v1/conference/1/" 

我已經試過C#代碼通過JSON數據與WebService的

HttpWebRequest httpWReq =(HttpWebRequest)WebRequest.Create(string.Format("https://tsmgr.tsecurevideo.com/api/admin/configuration/v1/conference/2/")); 
    Encoding encoding = new UTF8Encoding(); 
    string postData = "{\"pin\":\"1234\"}"; 
    byte[] data = encoding.GetBytes(postData); 

    httpWReq.ProtocolVersion = HttpVersion.Version11; 
    httpWReq.Method = "POST"; 
    httpWReq.ContentType = "application/json";//charset=UTF-8"; 

    string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("admin" + ":" + "password")); 
    httpWReq.Headers.Add("Authorization", "Basic " + credentials); 
    httpWReq.ContentLength = data.Length; 


    Stream stream = httpWReq.GetRequestStream(); 
    stream.Write(data, 0, data.Length); 
    stream.Close(); 

    HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse(); 
    string s = response.ToString(); 
    StreamReader reader = new StreamReader(response.GetResponseStream()); 

我收到錯誤

The remote server returned an error: (501) Not Implemented.

+2

你有什麼步驟來嘗試自己診斷問題?你有什麼異常?它在哪裏拋出?什麼是堆棧跟蹤?請參閱http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx,瞭解如何提出問題,以便產生最佳答案 – Jonny

+0

的一些提示有可能在那裏在執行該方法時出錯? – faby

回答

0

嘗試以這種方式

string auth = string.Format("{0}:{1}", "admin","password"); 
string data = Convert.ToBase64String(Encoding.ASCII.GetBytes(auth)); 
string credentials= string.Format("{0} {1}", "Basic", data); 
httpWReq.Headers[HttpRequestHeader.Authorization] = credentials; 

發送憑據Encodi中的文檔請參見here ng.ASCII

0

HTTP spec

501 Not Implemented

The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource.

聽起來就像是服務器不支持PATCH方法。