I am trying to create a little command-line script, using the API, to create a post that includes some text and an image.
This is almost entirely successful. I can upload a file; get a file_id for it, and include that file ID in a call to /posts endpoint. That call also includes the channel_id and the text I’d like to post.
I get a 201 response. I’d both anticipate and desire for the image to be displayed as if I’d clicked on the paper clip icon and uploaded it.
However, when I go the Web or desktop client, I see the text and a tiny icon indicating a broken file link. Clicking on the icon shows the name of the file that I uploaded.
The body of my request includes
@body = {
“channel_id”: channel_id,
“message”: “This is my fabulous post”,
“file_ids”: [file_id]
}
Here’s the
{“id”:“q8stj7mju3fwppns18ifmtde8e”,“create_at”:1727694235070,“update_at”:1727694235070,“edit_at”:0,“delete_at”:0,“is_pinned”:false,“user_id”:“dm48rz7okfbwpjfmenp1k4jm8w”,“channel_id”:“6xfkehrzgbbhxfwt9owqtfnmuo”,“root_id”:“”,“original_id”:“”,“message”:“This is my fabulous post”,“type”:“”,“props”:{},“hashtags”:“”,“file_ids”:[“wftm83adbjb9ppp4zryernktuc”],“pending_post_id”:“”,“reply_count”:0,“last_reply_at”:0,“participants”:null,“metadata”:{“files”:[{“id”:“wftm83adbjb9ppp4zryernktuc”,“user_id”:“dm48rz7okfbwpjfmenp1k4jm8w”,“post_id”:“q8stj7mju3fwppns18ifmtde8e”,“channel_id”:“6xfkehrzgbbhxfwt9owqtfnmuo”,“create_at”:1727694233304,“update_at”:1727694233304,“delete_at”:0,“name”:“airbnb.jpg”,“extension”:“jpg”,“size”:0,“mime_type”:“image/jpeg”,“mini_preview”:null,“remote_id”:“”,“archived”:false}]}}
I must say, regretfully, that the API documentation for /files, /uploads, and /posts is pretty weak; bereft of good examples, and not at all clear on which tasks to be performed, and in which order.