[Solved-3 Solutions] HTTP POST Returns Error: 417 “Expectation Failed.”
Error Description:
- When we try to POST to a URL it results in the following exception:
The remote server returned an error: (417) Expectation Failed.
- Here's a sample code:
Solution 1:
- 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:
- Some servers choke on that header and send back the 417 error you're seeing.
- Give that a try.
Solution 2:
Solution 3:
- If you are using "HttpClient", and you don't want to use global configuration to affect all your program you can use:
- I you are using "WebClient" I think you can try to remove this header by calling: