Can't add a media to a tweet - Javascript


I think there’s something wrong with my code but I can’t figure out what.

This is the part where I upload an image to get a media_id.{ formData: { media: fs.readFileSync('./images/flower.jpg') }, url: '', json: true, oauth: oauthOptions }, function (err, response, body) {

The response is exactly what I expected.
{ media_id: 875811238164521000, media_id_string: '875811238164520960', size: 166837, expires_after_secs: 86400, image: { image_type: 'image/jpeg', w: 500, h: 600 } }
Then, I use this media_id_string for my next request:{ formData: { status: 'test', media_ids: '875811238164520960'}, url: '', json: true, oauth: oauthOptions }, function (err, response, body) {

There is no error. My tweet appears on my timeline but without the image.

I’d like to know what I’m doing wrong.


I’m guessing that you have a recent tweet with the text “test” that doesn’t have the image attached and when you try to create a new one it’s rejected for having duplicate text. Try adding a random number in the status text while testing.


It doesn’t work. Plus, before each attempts, I delete the tweet to try again.

The thing is: I do have a normal response:
{ created_at: 'Fri Jun 16 21:17:07 +0000 2017', id: 875824585555443700, id_str: '875824585555443715', text: 'test1234', truncated: false, entities: { hashtags: [], symbols: [], user_mentions: [], urls: [] }, source: '<a href="" rel="nofollow">New Application</a>', in_reply_to_status_id: null, in_reply_to_status_id_str: null, in_reply_to_user_id: null, in_reply_to_user_id_str: null, in_reply_to_screen_name: null, user: { [...] }, geo: null, coordinates: null, place: null, contributors: null, is_quote_status: false, retweet_count: 0, favorite_count: 0, favorited: false, retweeted: false, lang: 'en' }

Nothing about media in the response by the way.