Home > Back-end >  Tweepy error - 'Unexpected parameter: status'
Tweepy error - 'Unexpected parameter: status'

Time:11-29

I'm using Tweepy to post an image with text but getting an error for the text (status) piece -

Unexpected parameter: status

I'm sure I'm using the correct method; status is valid for the text body of the post. This is my code -

post =  api.media_upload("/Users/me/p1/images/"   img_file, status=fileName[:-6])

Not only do I get this weird error, but there is no post made to Twitter, either image or text.

If I use post = api.update_status(fileName[:-6]) to post just text it works fine. I've checked Tweepy docs but I can't see an issue with my code or my use of status.. Any help appreciated.

CodePudding user response:

As the warning says, API.media_upload does not expect a status parameter.
It is not an equivalent replacement for API.update_status_with_media.
As per Tweepy's documentation, API.media_upload returns a media object.
You need to use this media object's ID and pass it when creating the Tweet, e.g. with API.update_status.
For more information, see the Twitter API documentation on uploading media.

  • Related