Open
Description
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:
- 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,
});
- Endpoint used or code example of what's happening wrong
const mediaId = await client.v1.uploadMedia('./paris.gif', {
mimeType: 'image/gif,
});
- Error stack trace, and if possible, error content (
err.toJSON()
whenerr
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
Metadata
Metadata
Assignees
Labels
No labels