« Blend Missing Method - Silverlight Isolated Storage | Main | Debugging Expression Blend Design Time Errors »

WebRequest - Expectation Failed

I’ve been playing around for a few month’s with a Silverlight Twitter Client.  It uses a WCF proxy to access the Twitter service because Twitter does not publish policy files.  The proxy also handles some of the hard work so the Twitter client just consumes a nice object model instead of the REST XML produced by Twitter.

Anyway, all of a sudden my posts stopped posting to Twitter and the Twitter server started returning the following:

The expectation given in the Expect request-header field could not be met by this server.

So after a little research it would appear that WCF is adding that by default to the header sent.  You can read more about  the 100-continue here in the spec.

There’s a couple ways to deal with this, I handled it by setting the property on the HttpWebRequest.  If you were dealing with a WebRequest object instead of a HttpWebRequest you would need to cast it to access the property.

((HttpWebRequest)webRequest).ServicePoint.Expect100Continue = false;

You can also modify the default behavior by setting the Expect100Continue property on ServicePointManager

System.Net.ServicePointManager.Expect100Continue = false;

If you want to connect on twitter you can find me at http://twitter.com/davidyack

Posted on Friday, December 26, 2008 at 10:16AM by Registered CommenterDavid Yack | CommentsPost a Comment

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>