Question

Include image attachment in Mastodon Status using Webhooks

  • 28 August 2023
  • 2 replies
  • 195 views

By following https://blog.fosketts.net/2022/11/13/how-to-auto-post-to-mastodon-using-zapier/ and the official Mastodon API documentation I’ve been able to setup a Zapier automation using Webhooks by Zapier to post a Status (a title + URL) to a Mastodon instance.

Also I’ve been able to upload a media item using the endpoint “/api/v2/media”. And valid ID is returned after this step in Zapier. 

https://docs.joinmastodon.org/methods/statuses/#create

https://docs.joinmastodon.org/methods/media/

There is an issue with including the image attachment to the Status. According to the blog-post and the API documentation an Attachment ID is to be included as a media_ids[] in Data. But for some reason this doesn't seem to work.There is not error but also no image is included.

Step Configuration:

This works for a regular Status post. But including a valid Attachment ID for media_ids[] doesnt have the desired effect.  


I'm using the https://mastodon.social/ instance. 

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 2
Badge +1

I think these parameters can work if you change your Payload Type from json to form. The square brackets refer to mastodon wanting an array. In common form convention, setting media_ids[] can implicitly make an array. 

If that doesn’t work, try removing the square brackets and just calling it meda_ids

If that doesn’t work - share the screenshot, and we’ll see what makes sense next!

Changing for Step 2 (Post Status to Mastodon) the Payload Type from json to form solved the issue!  @raydeckthanks.

Step 1 (Upload Image to Mastodon) with “/api/v2/media” does work through Payload Type json. 

What I also discovered if you run Step 2 again (“ Retest Step”) during configuring of the Zap. The Status is successfully submitted to Mastodon again, but the image is not attached. This is no issue when the Zap is running. But something to be aware of during testing. Maybe an image can only be attached to one Status. 

Removing the square brackets from media_ids[] and just calling it media_ids when using Payload Type json didn't work...