411 Length Required for https://api.twitter.com/oauth/request_token


#1

Hi,

Within the last 30 minutes or so, all of our requests to https://api.twitter.com/oauth/request_token which had previously been working return:

reply: 'HTTP/1.1 411 Length Required\r\n'
header: Content-Length: 0
header: Connection: close

Our request looks like this:

send: 'POST /oauth/request_token?oauth_nonce=38615815&oauth_timestamp=1351297972&oauth_consumer_key=<consumer key>&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=wReGHyCnKgGl%2FJ4mK%2F7kVZdu624%3D&oauth_callback=<callback> HTTP/1.1\r\nHost: api.twitter.com\r\nAccept-Encoding: identity\r\n\r\n'

I can’t seem to find any updates regarding changes to this endpoint. Was any change recently rolled out? Thanks!


#2

We are now sending a Content-Length: 0 in our request and everything seems to be working again in case anyone else was not doing that before and runs into this.


#3

Hi David,

We’re looking into this. Thanks to all who’ve pointed it out. Your stop-gap solution is spot-on.


#4

Thanks a ton. Setting the content-length fixed the issue!


#5

Me having same problem. I can even not set the contentLength because I am using dll that calls the method Twitterizer.OAuthUtility.GetRequestToken(). So please resolve the issue soon.


#6

Hello. I have same problem too. I’m using tmhOAuth . I wonder the services with twitterAPI which using tmhOAuth is running or not now .


#7

Hello again . Here , I report that I solved my probrem . If you using tmhOAuth , try the following process .

Change $twitter->request("POST",$twitter->url("oauth/request_token",""),array("oauth_callback" => url)); To $twitter->request("POST",$twitter->url("oauth/request_token",""),array("oauth_callback" => url ,"Content-Length" => 0));

And then

Change $twitter->request("POST",$twitter->url("oauth/access_token","")); To $twitter->request("POST",$twitter->url("oauth/access_token",""),array("Content-Length" => 0));
* $twitter = new tmhOAuth( array ("consumer_key" => consumer_key , "consumer_secret" => consumer_secret));

Thanks a ton , thank you David !


#8

I’m having the same issue using the tweepy library for python. There doesn’t seem to be anyway to modify the headers… If anyone knows I’d be very grateful!

Cheers,
Tom


#9

Sorry! Should have done a bit of googling before posting…

For reference, in tweepy the code is objAPI.update_status(‘tweet text’, headers={‘content-length’: 0})

Can anyone at Twitter confirm what will happen when they resolve the root cause? Will we need to remove our workarounds or should it continue to work?


#10

Excuse me, Could someone fix this problem?


#11

For those using the tmhOAuth library, you can find a couple solutions there: https://github.com/themattharris/tmhOAuth/issues/94


#12

seems so that twitter’s own web interface has the problem to create new access tokens, too.


#13

I’m seeing the same problem too.


#14

I have the same problem, really need this sorted asap.


#15

We have the same bug !


#16

I’m working with our operations team to resolve the HTTP 411 issues you’re experiencing. We’re being extra strict with the HTTP spec in this case.

In the meantime, I’ve mitigated the issues you’re encountering on dev.twitter.com’s application management interfaces.


#17

Meanwhile the Twitter guys fix the problem from its root you can set ‘Content-Length’ in the ‘headers’ array in the line 625 of tmhOAuth.php from

$this->headers[‘Content-Length’] = ‘’;
to

$this->headers[‘Content-Length’] = ‘0’;

this will fix the problem.

Hope it helps!

edit: only for themattharris lib on php


#18

if you are using my library ‘tmhOAuth’, update to 0.7.1 (latest master) as that includes a fix which works around this. You can get it here: https://github.com/themattharris/tmhOAuth/