Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Error when uploading GIFs #519

Open
anaisberg opened this issue Mar 1, 2024 · 0 comments
Open

[bug] Error when uploading GIFs #519

anaisberg opened this issue Mar 1, 2024 · 0 comments

Comments

@anaisberg
Copy link

Describe the bug
When trying to upload GIFs using the uploadMedia endpoint, I get an {"code":1,"name":"InvalidMedia"} error.
Uploading images works well with png/jpg however.

To Reproduce
Please indicate all steps that lead to this bug:

  1. Request client setup (login method, OAuth2 scopes if applicable...)
 import { TwitterApi } from 'twitter-api-v2';
 const client = new TwitterApi({
    appKey: XXXX,
    appSecret: XXXX,
    accessToken: XXXX,
    accessSecret: XXXX,
 });
  1. Endpoint used or code example of what's happening wrong
const mediaId = await client.v1.uploadMedia('./paris.gif', {
  mimeType: 'image/gif,
});
  1. Error stack trace, and if possible, error content (err.toJSON() when err is the caught error; take care of removing authentication HTTP headers)
{
"media_id":1763597253904670720,
"media_id_string":"1763597253904670720",
"media_key":"16_1763597253904670720",
"size":384852,
"processing_info":{
  "state":"failed",
  "progress_percent":99,
  "error": {"code":1,"name":"InvalidMedia"}
  }
} 

Expected behavior
The gifs is uploaded, state success

Version

  • Node.js version : v18
  • Lib version : "twitter-api-v2": "^1.15.0"
  • OS (especially if you use Windows) : macOs 14.3.1

Additional context

After looking into the code, I realized that the media_category computed for gifs is TweetGif (in the getMediaCategoryByMime function), where in the API documentation, it is specified that the media_category should be tweet_gif

@anaisberg anaisberg changed the title [bug] [bug] Error when uploading GIFs Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant