Put 參數傳送方法
I was trying to do this the easy way with C#, but apparently that is not the tool of choice from looking at the code samples :)
轉至: Link
private bool PutData(string sURL, string sData, out string sResponse) { try { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); byte[] arr = encoding.GetBytes(sData); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sURL); request.Credentials = new NetworkCredential("", " "); request.Method = "PUT"; request.ContentType = "text/xml"; request.ContentLength = arr.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(arr, 0, arr.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream respStream = response.GetResponseStream(); StreamReader reader = new StreamReader(respStream); sResponse = reader.ReadToEnd(); } catch { sResponse = ""; return false; } return true; }
轉至: Link
留言
張貼留言