Hi,
I got error The remote server returned an error: (400) Bad Request. when execute this line HttpWebResponse response = (HttpWebResponse)request.GetResponse();
my code is:
try
{
string _url = "http://mydomain/Api/Log/";
string str = id.ToString();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] arr = encoding.GetBytes(str);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(_url);
request.AllowWriteStreamBuffering = false;
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = arr.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(arr, 0, arr.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string returnString = response.StatusCode.ToString();
}
catch(WebException ex) {
Android.Util.Log.Error("http errror", ex.Message );
}
i want to know how it works for post and put json request AND please GUIDE for writing "url" of web request for Post and put.
please help to solve this.
Thanks