Thursday, July 1, 2010

The request failed with HTTP status 417: Expectation failed.

When using WebServices and calling some Web Methods, you may come across to this exception: 
"The request failed with HTTP status 417: Expectation failed."

Solution:


It is easy, here are two alternative ways:

1) We need to have this line of code before making any web requests.


1:
System.Net.ServicePointManager.Expect100Continue = false;


2) Add these lines to the application's configuration file (between <configuration> and </configuration>):

1:
2:
3:
4:
5:
<system.net>
 <settings>
  <servicePointManager expect100Continue="false" />
 </settings>
</system.net>


While this workaround is nice, I think a better long term solution is to upgrade/replace the proxy server to handle 100-continue calls.

So far in this short tip we've learned what is Expect 100, how it is caused and how to workaround this expectation.

No comments:

Post a Comment