HTTP POST Returns Error: 417 “Expectation Failed.”

后端 未结 10 910
离开以前
离开以前 2020-11-28 18:04

When I try to POST to a URL it results in the following exception:

The remote server returned an error: (417) Expectation Failed.

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 18:22

    If you are using "HttpClient", and you don't want to use global configuration to affect all you program you can use:

     HttpClientHandler httpClientHandler = new HttpClientHandler();
     httpClient.DefaultRequestHeaders.ExpectContinue = false;
    

    I you are using "WebClient" I think you can try to remove this header by calling:

     var client = new WebClient();
     client.Headers.Remove(HttpRequestHeader.Expect);
    

提交回复
热议问题