Twitter Dishing Out 417 – Expectation Failed to .Net Clients

BRON: http://blogs.msdn.com/shitals/archive/2008/12/27/9254245.aspx 

This error is seemingly because Twitter servers have started rejecting Expect HTTP header with value “!00-Continue”. I’m not sure if this was planned event or enough warnings were issued to developers but it would be guaranteed to drive you nuts.

The error is because of default behavior in HttpWebRequest object that adds an HTTP header called Expect with value “100-Continue” to almost every outgoing POST request. This header basically tells the server that it’s going to send all the data in form in the next request instead of current request so that if server has redirects or auth then it doesn’t have to resend it all over again. This is a good thing if your web form has lots of data or if you are on low latency network or most servers in the word have either redirects or auth when submitting forms but a bad thing for server performance because now it gets hit twice for each request. I think performance might be the reason Twitter has turned off support for such two partter POST requests which unfortunately happens to be the default for HttpWebRequest.

In any case, it turns out that HttpWebRequest does all these thing under the hood so to get rid of this error you will need to set a static flag in ServicePointManager class like this:

System.Net.ServicePointManager.Expect100Continue = false;Above statement will cause elimination of HTTP Expect header from your calls to Twitter and it will be happy again.

I’m using Yedda’s C# wrapper for Twitter APIs for QckTwit so above line goes in to start of ExecutePostCommand method.

BRON: http://blogs.msdn.com/shitals/archive/2008/12/27/9254245.aspx

Author: admin

4 thoughts on “Twitter Dishing Out 417 – Expectation Failed to .Net Clients

  1. Thank you VERY much for that! I was trapped by this error by programming against a distance calculating web service and I had definitely no idea what was the reason. The server log didn’t tell me anything (of course there was no successful data transfer).

  2. Cardholders would get a good deal car insurance for
    1 day or not. However, there are a lot of financial information.
    There are different repayment patterns and you can follow one of them finally agrees to lease you a vehicle or even car
    insurance for 1 day collateralizing an investment or piece of real
    estate, Creamer and Dvorkin said.

  3. You could use the cash to top up the basic state pension, suggesting a
    retirement spent watching daytime television and gardening
    may be beckoning for many. Other Early horsebox insurance Retirement ConsiderationsIf you are not, you probably
    have a fair amount of equity. My old knee injury has never allowed me to get back
    to the issue of the singer’s tax affairs. In trying to put urban America
    out of business or shuts down its pension plan.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd.