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 flow
The first Compose section has an expression of 'triggerMultipartBody(0)'. The second Compose section has an expression of '
The error I receive from this is:
Hey there!
Just curious if you ever got this to work. I am running into a similar issue.
Thanks!
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.
The child flow:
I'm having the same issue. Can you export the flow? I'm not quit understanding where to put the child flow?
The main flow which I trigger from the button is very simple:
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']}"
}
Update: Eliz you're a genius! It worked , all the kudos to you!
Hi I can't get this to work. Can you please look over to help?
I am getting a mismatch type error for string and object. This is how my http call to child looks.
Child flow:
Can you look over the issue that i am still having with this? I feel like i have tried to duplicate but still getting a type mismatch error from the child flow.
Hi @kmin !
It looks like you forgot to add curly brackets in the body when calling a child flow :
{
"content":"..."
}
Hi, I did forget the brackets but added it in but gets the same error message below. I am triggering this from postman using an .jpg file in the body. The JSON schema in the child i copied from this post. If i change the 'object' to 'string' there, i get over this error but fails in 1st in the child.
"The input body for trigger 'manual' of type 'Request' did not match its schema definition. Error details: 'Invalid type. Expected String but got Object.'. "
I have the same issue! With empty JSON Schema, I am getting "
Hello All,
So we are able to fix this eventually and get the multipart form data, by getting the form details and the attached file.
See the screenshot below for details.
Get JSON Data Base 64
triggerMultipartBody(0)['$content']
Decode JSON Data Base 64
decodeBase64(outputs('Get_JSON_Data_Base_64'))
Get File from Multipart form data
triggerMultipartBody(1)?['$content']
Convert the Base64 file to Binary
base64ToBinary(outputs('Get_File_from_Multipart_Form_Data'))
== Then pass the content output in the SharePoint Add attachment card.
So, this way, we are able to get the form data as well as get the attached file in the form data.
Cheers!
Hi AY.
Can you share the rest of the sample JSON file? I want to use correct key value pairs to handle files on Json Format, and the screenshot you have only include until phonenumber.
All the best...
The following post might help you. I have written this after wasting much time on file uploading to SharePoint.
Thanks
I also had that same error. My flow is running smoothly and then suddenly I am having that error.
You can fix it by just deleting the schema body of the trigger.
User | Count |
---|---|
95 | |
46 | |
21 | |
18 | |
17 |
User | Count |
---|---|
141 | |
50 | |
43 | |
40 | |
29 |