How can I get the media_id of an image from Twitter using n8n?

Hi everyone
I’m trying to post an image on Twitter/X using n8n. As per the API, I first need to upload the image and get a media_id, then use that media_id when creating the tweet.
What I tried
Added an HTTP Request node with:
Method: POST
URL: https://upload.twitter.com/1.1/media/upload.json
Auth: OAuth2 API (Twitter app credentials)
Body: image (binary data from OpenAI-generated image / image URL)
Problem
Instead of returning a media_id, Twitter keeps responding with:
403 Forbidden
or 404 Not Found
My Questions
What’s the correct way in n8n to upload an image and get the media_id?
Should I use OAuth 1.0a with user context instead of OAuth2?
Does anyone have a working workflow JSON or node setup that works for uploading media to Twitter?
:backhand_index_pointing_right: If anyone has solved this or has a working solution, please share — it will help me and others who want to automate Twitter posting with images in n8n.
Thanks in advance :folded_hands:

Hi @GAUTAM_KUMAR,
Please refer to this post:
https://community.n8n.io/t/post-media-to-x-twitter-via-api-new/90997
and let me know if you still have any issues.

Wow @mohamed3nan this is great stuff.

2 Likes

Hey there! The links is not avaliable anymore, could you check it?

I removed it,
Just post your question in a new topic and include the problem you’re experiencing.

I was just checking how was the correct procces and steps to upload and posted with images. Anyway, I’ll try around, and if had a problem will open a new topic. Thanks for reply anyway

Very well :clap:

Job well done :clap:

Great work !

@bartv
@mohamed3nan you are still not answering the question

@mohamed3nan hi there

Keep in mind that Bart is a busy guy. He deals with a lot more than just the forum.

Also things like this take some time to properly investigate and act upon.

We of course do not want to have community members banned or removed from the leaderboard without being 100% sure.

It is annoying that people act like this but for the leaderboard there is no worries. With reports like this they are checked and dealth with before the payout.

Ps. I am not an n8n employee, but am one of the navigators (mods). This is something I sadly do not have the tools nor time for to properly investigate myself.

2 Likes

I know that I’m not new to this..
It just means we’re probably going to be waiting a looooong time hopefully not months! :grinning_face_with_smiling_eyes:

I don’t really care about leaderboards, It’s just frustrating when someone playing/spam and a lot of people notice it and reject that behavior… That’s human nature, as far as I know!

I know @BramKn and thanks for replying, I appreciate it.

btw, I just deleted all my interactions with those accounts. It seems their goal is to drag us into their space..

1 Like

It’s funny how the same bot that hid my post is not seeing this wrong … because I don’t even know who @Nifemi_Emmanuel is