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
Reader Comments