Sending Feed Events with Attachments or Images
When sending feed events where the card includes an attachment section or an image section, it is possible to upload a document or image in the call to the Send Feed Event Endpoint and use it in the card.
Firstly, rather than calling the Send Feed Event Endpoint with a JSON body as per the documentation, you should call the endpoint with a Multipart form body. Simply put all the documented fields as key/value pairs in the multipart form.
Then, to send a document or image, add the document or image under the key attachment
. You should also send an attachment id under the key attachment_id
. Attachment ids must be in the form a-<UUID>
. Generate sample UUIDs here. For example a-ca6eb2fd-1327-443f-bbec-5f0856ba25ac
is a valid attachment id.
Because you're sending the atttachment id that will be assigned to the attachment you're uploading, you can use it in CardKit seciton fields such as image_url
or download_url
by specifying the value as https://api.joinblink.com/file/<attachment_id>
.
For example, if you're uploading an image in the attachment
field on the Send Feed Event Endpoint with attachment_id
set to a-ca6eb2fd-1327-443f-bbec-5f0856ba25ac
. You could then use the image in the CardKit JSON you send in the body
field as follows:
{
"sections":[
{
"type":"text",
"value":"Here's a nice image"
},
{
"type":"image",
"image_url":"https://api.joinblink.com/file/a-ca6eb2fd-1327-443f-bbec-5f0856ba25ac"
}
]
}
Updated almost 6 years ago