Handle multipart/form-data in logic app standard Http action
In logic app standard, I'm following this MS learn page to call an api with multipart/form-data body from the previous "Create_CSV_table" action:
On the right side is the sample config while on the left is mine:
This returns a httpStatusCode 500: Outgoing HTTP request ends with server failure.
From raw input I can see all variables are parsed correctly (the body is simply the header row of the CSV):
"method": "POST",
"headers": {
"Api-Key": "xxxxxxxxxxxxxxxxxxxxxxxx",
"Authorization": "*sanitized*"
},
"body": {
"$content-type": "multipart/form-data",
"$multipart": [
{
"body": "Employee ID,Time Off,Date,Hours,Timestamp,IsDeleted\r\n",
"headers": {
"Content-Disposition": "form-data; name=file; filename=LeaveDataTest.csv"
}
}
]
}
After reading William's post here, I also tried replacing the body inside the $multipart with
"body": {
"$content": "Employee ID,Time Off,Date,Hours,Timestamp,IsDeleted",
"$content-type": "text/csv"
}
But this returned BadRequest - The provided workflow action input is not valid.
I tested the endpoint with Postman which supports attaching a physical file and that's the only thing worked. From the working call's snippet, there's a boundary added and encoding used, but I assume the Http action in logic app would do the same under the hood?
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=file;'))
Please explain a bit more as the original MS documentation is too brief.