Adding Media to Twitter API V2 with HTTP Node

I’ve followed this to upload an image to Twitter via the 1.1 API: Tweet image - media type unrecognised - #2 by MutedJam

As we all know, the 1.1 API is no longer available to post Tweets, so the method used in this example to attach the media (media_ids) to an actual tweet doesn’t work with Twitter API V2.

I’ve found this: How to show an image in a v2 api tweet? - #5 by cloudworxx - Media APIs - Twitter Developers

Which says you need to format the media_ids inside a “media” field:

{"text": "Tweeting with media!", "media": {"media_ids": ["1455952740635586573"]}}

But I’m not sure how to do this with n8n using JSON and the “Using the fields below” boxes. I realize I can format the JSON from scratch, but that will screw up all the formatting in the tweet itself, and among many, many workflows, will create a lot of work for me to fix. I’m hoping there’s a way to make this work with the pre-defined boxes in n8n.

Here’s what I have. I don’t know what to put in the boxes under “name” and “value” for the media_id_string to make the media nest as Twitter API V2 requires.

I’ve tried dot notation and a colon, like “media.media_ids” and “media:media_ids” but (obviously) those didn’t work.

Hey @mmac,

What is the value of media_id_string? It looks like the API is expecting an array so in theory changing the Name of the value you are sending to media.media_ids[0] will do the job unless media_id_string coming from the previous node is already an array.

It’s a number, like 1274532057230957

What I get back, exactly, is:


Perfect in that case try media.media_ids[0] which looks to send the correct value.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.