Send a Tweet with a Media not working: 400 - 'Your media IDs are invalid.'
See original GitHub issueI 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:
- Created a year ago
- Comments:7
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.
Yes, I tweeted the same image in WebClient. it is working fine, Twitter supports jpg images.