I am making a Windows Phone 8 application where I need to send login credentials to web server(I am using RESTSHARP) and post authentication (response) , I have to do variety of tasks. I was using the following code base but I am getting Not Acceptable error message.
var client = new RestClient("http://com.example");
var request = new RestRequest("/REsource/", Method.POST);
// Json to post
request.AddParameter("username", userName.Text);
request.AddParameter("password", Password.Text);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
client.ExecuteAsync(request, response =>
{
MessageBox.Show(response.StatusCode.ToString());
if (response != null && ((response.StatusCode == HttpStatusCode.OK) &&
(response.ResponseStatus == ResponseStatus.Completed))) // It's probably not necessary to test both
{
}
else if (response != null)
{
MessageBox.Show(string.Format
("Status code is {0} ({1}); response status is {2}",
response.StatusCode, response.StatusDescription, response.ResponseStatus));
}
});
I tried HTTPResponseMessage part of HTTPCLient also and but dont know how to send a POST .