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
Solved! Go to Solution.
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.
Hi @SvenG ,
Which API do you currently use, and are there any documents for reference?
Best Regards,
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.