Way to send an image using the REST API?

Using the JS SDK, I can send a MediaMessage with the file from a file input control. Is there a way to do this with the REST API? I see there are options to send a message of type “image”, but I don’t see how to include the actual file itself.


	"receiver": "cardgroup-local-1003",
	"receiverType": "group",
	"category": "message",
	"type": "image",
		"text": "comment",
		"attachments": [
				"file": <what goes here?>

I tried including the base64 encoding of the file, but it didn’t work.

Hi Eric,

The attachments array can only be used when you have all the properties of attachment object like:

   "name": "filename.png",
   "extension": "png",
   "size": 29024,
   "mimeType": "image/png",
   "url": "<file url from your server>"

This allows you to add files from your system into a chat message.

If you want to send a file object directly to API similar to client-side SDKs, you can assign the file to files post body param as shown in the screenshot below:

1 Like

Thank you!

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