httpwebrequest fails with 417 expectation failed

April 17, 2007

Ive been trying to automate posting to one site for a while now and the code suddenly started failing with the message 417 expectation failed. Im using vb.net and the httpwebrequest and httpwebresponse classes.

The problem apparently is that the request gets sent with a Expect:100 continue header that this server doesn’t seem to like. Reverting back to http 1.0 wasn’t the best solution obviously…

The solution was to use set the property .ServicePoint.Expect100Continue of the webrequest to False.

Setting this worked fine, but when I used a proxy with the call, it failed as the proxy sent the 100 continue header on its own. The solution that I finally found was to add this code in your app.config file

<configuration>
<system .net>
<settings>
<servicepointmanager expect100Continue="false" />
</settings>
</system>
</configuration>

This works perfectly now 🙂

Incoming search terms:

Comments on this entry are closed.

Previous post:

Next post: