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.

Send a Tweet with a Media not working: 400 - 'Your media IDs are invalid.'

See original GitHub issue

I have problem for send a tweet with a media

There is my code :

`async function sendTweet(tweetID: string) {

await twitterClient.v1.uploadMedia(__dirname + "/../test.mp4", {
    mimeType: EUploadMimeType.Mp4,
}).then(async (data) => {
    const detail = (await twitterClient.v1.mediaInfo(data));
    console.log(detail);
    twitterClient.v2.reply('Test', tweetID, {
        media: {media_ids: [detail.media_id_string]}
    });
});

}`

And the error :

/Users/antoine/Documents/Projet/test/node_modules/twitter-api-v2/dist/client-mixins/request-handler.helper.js:103 return new types_1.ApiResponseError(errorString, { ^ ApiResponseError: Request failed with code 400 - Invalid Request: One or more parameters to your request was invalid. (see https://api.twitter.com/2/problems/invalid-request) at RequestHandlerHelper.createResponseError (/Users/antoineguespin/Documents/Projet/test/node_modules/twitter-api-v2/dist/client-mixins/request-handler.helper.js:103:16) at RequestHandlerHelper.onResponseEndHandler (/Users/antoineguespin/Documents/Projet/test/node_modules/twitter-api-v2/dist/client-mixins/request-handler.helper.js:252:25) at Gunzip.emit (node:events:513:28) at Gunzip.emit (node:domain:489:12) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { error: true, type: 'response', code: 400, headers: { date: 'Thu, 22 Sep 2022 20:39:11 UTC', server: 'tsa_f', 'set-cookie': [ 'guest_id=v1%3A166387915124632486; Max-Age=34214400; Expires=Mon, 23 Oct 2023 20:39:11 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None' ], 'api-version': '2.49', 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache, no-store, max-age=0', 'content-length': '208', 'x-access-level': 'read-write', 'x-frame-options': 'SAMEORIGIN', 'content-encoding': 'gzip', 'x-xss-protection': '0', 'x-rate-limit-limit': '200', 'x-rate-limit-reset': '1663879632', 'content-disposition': 'attachment; filename=json.json', 'x-content-type-options': 'nosniff', 'x-rate-limit-remaining': '194', 'strict-transport-security': 'max-age=631138519', 'x-response-time': '437', 'x-connection-hash': '7b8a0c793e806bc1055da8e5c93fc337550d26c86b486d1f57510115799caa67', connection: 'close' }, rateLimit: { limit: 200, remaining: 194, reset: 1663879632 }, data: { errors: [ [Object] ], title: 'Invalid Request', detail: 'One or more parameters to your request was invalid.', type: 'https://api.twitter.com/2/problems/invalid-request' }, errors: [ { parameters: [Object], message: 'Your media IDs are invalid.' } ] }

Thanks in advance

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
antoineguescommented, Oct 12, 2022

All the code you need is in my first message, but check your media is compatible with twitter. You can test on send it on twitter with your browser. If you need more help, don’t hesitate to ask.

0reactions
sanyamjain04commented, Nov 3, 2022

Yes, I tweeted the same image in WebClient. it is working fine, Twitter supports jpg images.

Read more comments on GitHub >

github_iconTop Results From Across the Web

V2 Tweet with media error "Your media IDs are invalid"
I'm trying to post a tweet with a media attachment, which is not going so well. I'm able to upload the media and...
Read more >
Tweet posting with media_ids fails · Issue #46 - GitHub
Obtain media ID using POST media/upload twitter API endpoint: ... This request throws an HTTPException 400, and with an error message:.
Read more >
Twitter API Response Codes & Error Support
Get Twitter API response codes and error support through Twitter Developer here. ... There was no new data to return. Troubleshooting tips. Code....
Read more >
How to Fix Twitter Error: Some of your Media Failed to Upload
Another way to fix the Twitter media upload error is to disable the VPN server you are using. Disconnect the VPN service and...
Read more >
Android: "400 bad request" error when trying to tweet with ...
OK, so it turned out it was due to a stupid mistake from my part. When I posted the image with twurl, I...
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