0

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.

4

1 回答 1

0

根据这个 MSDN 论坛主题,这可能是由不支持“100 继续”期望的代理引起的。

作为一种解决方法,将ServicePointManager.Expect100Continue或设置HttpRequestHeaders.ExpectContinuefalse

于 2013-08-23T11:12:07.937 回答