cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SvenG
Helper I
Helper I

Send multi-part form data with flow HTTP task

Hi,

 

I have to repost this question as this forum had an issue with my original post.

I'm struggling with multi-part form data. I need to send a binary file to REST API with plain HTTP and no json data.

How is this possible with the flow HTTP task?

 

It's also not possible to upload an image here.

Please see screenshot in link: Flow Task 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

While searching through similar post here I came to some conclusions. 

What I've found out so far is that one can use a special json syntax for the HTTP body.

 

 

I got it working now:

 

 

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"file\"; filename=\"test.pdf\""
      },
      "body":  {
        "$Content-type": "@{items('Auf_alle_anwenden')?['ContentType']}",
        "$content": @{items('Auf_alle_anwenden')?['ContentBytes']}
      }
    },
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"type\""
      },
      "body": "voucher"
    }
  ]
}

 

 

There was an issue that the API accepts only binary data.  I could resolve it by removing the base64 encoding found in a similar thread.

 

It's really bad that there is no documentation about the HTTP task at all. 

View solution in original post

3 REPLIES 3
v-bacao-msft
Community Support
Community Support

 

Hi @SvenG ,

 

Which API do you currently use, and are there any documents for reference?

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-bacao-msft 

 

I'm using this API and try to upload a file. They have working example of curl and postman.

 

Thanks for your support

Sven

 

 

Edit, the question now is:

What's the correct flow task setup for the following curl command:

curl https://api.lexoffice.io/v1/files
-X POST
-H "Authorization: Bearer {accessToken}"
-H "Content-Type: multipart/form-data"
-H "Accept: application/json"
-F "file=@{PathToImage}" -F "type=voucher"

 

While searching through similar post here I came to some conclusions. 

What I've found out so far is that one can use a special json syntax for the HTTP body.

 

 

I got it working now:

 

 

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"file\"; filename=\"test.pdf\""
      },
      "body":  {
        "$Content-type": "@{items('Auf_alle_anwenden')?['ContentType']}",
        "$content": @{items('Auf_alle_anwenden')?['ContentBytes']}
      }
    },
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"type\""
      },
      "body": "voucher"
    }
  ]
}

 

 

There was an issue that the API accepts only binary data.  I could resolve it by removing the base64 encoding found in a similar thread.

 

It's really bad that there is no documentation about the HTTP task at all. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,902)