POST reply api request - attachment using web request

Hello,
We are struggling with attachments using Post API for replies. I didn’t find relevant information in API docs. Is there any method to raise a new reply with an attachment using a Web request? Examples only point a local file that cant be used in Logic apps.

1 Like

This took me a little while to figure out… hopefully the below can make some sense - or help you out. But I effectively used dataURI to Binary in the body.

Please note the Api accepts only an array for files, which can be seen ‘attachments’.

Also if you are updating a ticket, it will be PUT.

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "body": @{dataUriToBinary(body('Parse_JSON_-_FormData')?['attachment1'])},
      "headers": {
        "Content-Disposition": "form-data; name=\"attachments[]\"; filename=\"@{body('Parse_JSON_-_FormData')?['attachment1_name']}\"",
        "Content-Type": "image/jpeg"
      }
    }
  ]
}
2 Likes

Many thanks.
Would You like also send the body(‘Parse_JSON_-_FormData’)?[‘attachment1’]?
It will also be helpful.

You are a saint, thank you!!

1 Like

So the way I have this logic app setup is it receives form data from a webpage.

I first used Compose to organise the data:

{
  "attachment1": "@{triggerFormDataValue('attachment1datauri')}",
  "attachment1_name": "@{triggerFormDataValue('attachment_01name')}",
.......
}

Then Parse JSON

{
    "properties": {
        "attachment1": {
            "type": "string"
        },
        "attachment1_name": {
            "type": "string"
        },
....
   }
}
1 Like

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