HTTP POST Returns Error: 417 “Expectation Failed.”

后端 未结 10 872
离开以前
离开以前 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:39

    System.Net.HttpWebRequest adds the header 'HTTP header "Expect: 100-Continue"' to every request unless you explicitly ask it not to by setting this static property to false:

    System.Net.ServicePointManager.Expect100Continue = false;
    

    Some servers choke on that header and send back the 417 error you're seeing.

    Give that a shot.

提交回复
热议问题