cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Working with multipart form data from HTTP trigger

Hi,

 

I'm trying to create a Power Automate flow which takes a file from multipart form data received via an HTTP trigger and then creates this file within OneDrive or SharePoint.

 

I've found a few older tutorials online which have enabled me to get to the stage where I can access the multipart form data and convert the base64 encoded version of the file into binary. If I run my Power Automate flow with only these steps, then it runs successfully. However, as soon as I add an extra block to the flow to do anything, I get back an InvalidRequestContext error from the flow.

 

Here's the version of the flow which works:

 

Working version of Power Automate flowWorking version of Power Automate flow

 

The first Compose section has an expression of 'triggerMultipartBody(0)'. The second Compose section has an expression of '

base64ToBinary(triggerMultipartBody(0)['$content'])'.
 
At this point, I add a step to create a file in OneDrive using a dummy file name and the output of the second Compose section.
 
Screenshot of non-working Power Automate flowScreenshot of non-working Power Automate flow

 

The error I receive from this is:

 

{
"error": {
"code": "InvalidRequestContent",
"message": "The input body for trigger 'manual' of type 'Request' must be of type JSON, but was of type 'multipart/form-data; boundary=--------------------------190915140118851309356544'."
}
}
 
I receive this same error message even if I try to create a static file without accessing the output of the second Compose section.
 
I've got a dummy JSON schema in the HTTP request, but the flow generates the same errors with or without this. In terms of the request, I'm sending it from Postman with a 'form-data' body which contains a single PNG file, and haven't changed anything else in Postman other than pasting in the HTTP trigger URL and selecting 'POST' as the HTTP method.
 
Would anybody know what's happening here?
5 REPLIES 5
Highlighted
New Member

Re: Working with multipart form data from HTTP trigger

Hey there!

 

Just curious if you ever got this to work. I am running into a similar issue.

 

Thanks!

Highlighted
Helper I
Helper I

Re: Working with multipart form data from HTTP trigger

Hi!

I had the same problem.

What is more - if I delete the creation of file step - flow run with success.

The solution for me was to call child flow (thru HTTP request) with step to create file.

 

The main reason for the error you get is that trigger "When a HTTP request is received" cannot receive any type but application/json. So in trigger leave JSON Schema empty.

 

eliz_talent_0-1598945241791.png

Untitled.png

The child flow:

Untitled.png

eliz_talent_2-1598945673910.png

 

Highlighted
New Member

Re: Working with multipart form data from HTTP trigger

I'm having the same issue. Can you export the flow? I'm not quit understanding where to put the child flow?

Highlighted
Helper I
Helper I

Re: Working with multipart form data from HTTP trigger

The main flow which I trigger from the button is very simple:Untitled.png

The last step is to send a request to child flow.

In URI you should specify the URI from the trigger of the child flow.

The Body:

{
"content": "@{triggerMultipartBody(0)['$content']}"
}

Highlighted
New Member

Re: Working with multipart form data from HTTP trigger

Update: Eliz you're a genius! It worked , all the kudos to you!

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,658)