Sample for HTTPWebRequest using PUT Method.
try
{
string str = "test";
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] arr = encoding.GetBytes(str);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url");
request.Method = "PUT";
request.ContentType = "text/plain";
request.ContentLength = arr.Length;
request.KeepAlive = true;
Stream dataStream = request.GetRequestStream();
dataStream.Write(arr, 0, arr.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string returnString = response.StatusCode.ToString();
}
catch {}
4 comments:
this is good script, i need php script for same functionality that making put method call to API using php.
Simple, nice and concise. Shows what is needed to be done correctly.
Although a little explanation would be better.
it will be better if u add how to send image data as byte array
it will be better if u add how to send image data as byte array
Post a Comment