Skip to content
Advertisement

tweepy error response status code 400

I’m trying to write a simple twitter bot using python and tweepy. The code is as follows:

import tweepy
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxx'
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxx'
ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
ACCESS_SECRET = 'xxxxxxxxxxxxxxxxx'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

api.update_status('hi')

I get the following error:

TweepError: Twitter error response: status code = 400

I would like some info on how to avoid this error

Advertisement

Answer

This may be a bug that emerged in the 3.2.0 release of Tweepy. See this issue opened on GitHub. In that issue, TylerGlaiel notes that api.update_status fails if called thus:

api.update_status('Test')

But works if called like so:

api.update_status(status='Test')

I have also found this works. I imagine a fix will be out before long.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement