Solved

API Create conversation with attachments

  • 29 December 2022
  • 2 replies
  • 81 views

Badge +2

Hello

I am trying to create a conversation with an attachment via API Create conversation (frontapp.com)

Currently, I am receiving new messages but without attachments.

 

My code looks like this:

$headers=@{}

$headers.Add("Accept", "application/json")

$headers.Add("Content-Type", "application/json")

$headers.Add("Authorization", "Bearer [my code]")

$response = Invoke-WebRequest -Uri 'https://api2.frontapp.com/channels/cha_XXX/messages' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"to":["securitydesk@example.com"],"options":{"archive":false},"attachments":["data:text/plain;name=test.txt;base64,aBcDeF=="],"body":"test"}'

 

icon

Best answer by Support Engineering 29 December 2022, 19:40

View original

2 replies

Userlevel 1
Badge +5

Taking a look at the above request, you'll want to make sure you change the HTTP Content-Type header to multipart/form-data. You can take a look at a Front API attachment example with some more information here.

 

Also, the options needs to be sent as options[archive]:

 

 

--Leslie

Badge +2

It works!!!

THANKS!

Sent from Front

Reply