question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when sending GIF with Tweepy

See original GitHub issue

Hi,

I want to send a GIF with Tweepy but I’ve an error whereas with an JPG or PNG, it’s ok. Here is the simple script:

#!/usr/bin/python

import tweepy

CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_TOKEN = ""
ACCESS_TOKEN_SECRET = ""

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

api = tweepy.API(auth)

api.update_with_media(filename="/root/image.gif")

The error encountered :

Traceback (most recent call last):
  File "./test.py", line 15, in <module>
    api.update_with_media(filename="/root/image.gif")
  File "/usr/local/lib/python2.7/dist-packages/tweepy/api.py", line 231, in update_with_media
    )(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 243, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 189, in execute
    raise TweepError('Failed to send request: %s' % e)
tweepy.error.TweepError: Failed to send request:

tweepy 3.4.0 python 2.7.9 debian 8.2

Any idea ? Thanks

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
meereeumcommented, Mar 2, 2016

@thomaslawn try:

pic = api.media_upload('PBR.gif')
api.update_status(status = 'test', media_ids = [pic.media_id_string] )

I think the media_ids kwarg expects a list (or other iterable).

0reactions
Harmon758commented, Sep 2, 2019

As pointed out, this seems to have been an issue with large POST requests with requests and urllib3 (https://github.com/urllib3/urllib3/issues/717).

I think the media_ids kwarg expects a list (or other iterable).

That’s correct, although unrelated to this issue.

For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/.

@airjump That’s not related to this issue. However, that also seems to have been an issue with requests. See #687.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions — tweepy 4.12.1 documentation
If you are encountering a 400 Bad Request error when uploading large GIFs or other errors/issues with uploading videos, make sure to pass...
Read more >
How can i respond to tweets with images with tweepy and ...
i'am using tweepy and i dont reach to tweet with an image in my response. When i run my code the console says...
Read more >
An error is detected when attaching an image to the welcome ...
This is the endpoint I'm trying to create the welcome message for. ... When I try to attach an image here, it says...
Read more >
Twitter API Response Codes & Error Support - Twitter Developer
Get Twitter API response codes and error support through Twitter Developer here.
Read more >
Twitter error: “media type unrecognized” when creating ...
The error “media type unrecognized” usually originates from the Image, Video Or GIF field in the 'Create Tweet' in Twitter action step.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found