azuremultipartform-dataazure-logic-appsazure-http-trigger

How to add multiple parts in multipart/form-data in an Azure Logic App


I am using Azure logic apps to send a file over HTTP using multipart/form-data. Unfortunately it isn't clear to me how to do the multipart of the request.

I have read the official documentation of microsoft on it. In their example they are only adding a file. I need to add some more parts to the form. In postman it looks like this:

enter image description here

When using a proper endpoint and proper key-value pairs for the form-data it works.

Sending the same request through the logic app doesn't work. I presume the body of my request doesn't look right. This is what it looks like now:

Current body

I would think that the body of the first part, so the part with name=file in the Content-Disposition of its header, should contain the actual content of the file.

I have come across the following answers to questions which are similar to mine but not exactly:

https://stackoverflow.com/a/59884777
https://stackoverflow.com/a/72138645

The first answer mentions that you can just add similar objects to the file object with correct form field names. However I can't seem to figure out what that would look like.

The second answer goes over adding one part to the form.

Any help on this topic would be greatly appreciated.


Solution

  • For anyone struggling with this, it seemed the body in my request was correct. I forgot to add the header

    "Content-Type": "application/json"

    to the first part. That is needed because I am sending a JSON file.