cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SvenG
Level: Powered On

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
SvenG
Level: Powered On

Re: Send multi-part form data with flow HTTP task

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
Community Support Team
Community Support Team

Re: Send multi-part form data with flow HTTP task

 

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.
SvenG
Level: Powered On

Re: Send multi-part form data with flow HTTP task

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"

 

SvenG
Level: Powered On

Re: Send multi-part form data with flow HTTP task

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

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (4,543)