I am using HttpClient.PostAsync()
method to send post request to my web service api.
I am passing api URL address along with queryString parameters in it..
but PostAsync()
method is not working correctly, giving an error :
Status Code 417 expectation failed.
public override async void SendPostRequest(REQUEST_NAME reqName, IDictionary<string, object> args)
{
var _client = new System.Net.Http.HttpClient();
_client.BaseAddress = new Uri("http://www.example.com/api/v2.0/");
_client.MaxResponseContentBufferSize = 256000;
string queryString = "?";
string url = reqName.ToString() + ".json" + queryString;
string queryStringparam = "";
foreach (KeyValuePair<string, object> param in args)
{
queryStringparam += param.Key + "=" + param.Value + "&";
}
// queryStringparam=name="abc&age=25&event=browsed&url=www.google.com"
var response = await _client.PostAsync(url, new StringContent(queryStringparam));
if (response.IsSuccessStatusCode)
{
}
May be I am passing parameters in wrong way in PostAsync()
method.
Please give me your suggestion about it. Thanks.