I am trying to use Logic Apps to submit a form to external API, including uploading a PDF file.
Two methods were used and none of them worked. Here is the detail.
Method #1: Use "Call service endpoints over HTTP or HTTPS from Azure Logic Apps"
https://zcusa.951200.xyz/bs-latn-ba/azure/connectors/connectors-native-http#content-with-multipartform-data-type
Result: pdf file was accepted by API but not readable
Code:
"body": {
"$content-type": "multipart/form-data",
"$multipart": [
{
"body": {
"content": "@{body('Get_blob_content')}",
"Content-Type": "application/pdf"
},
"headers": {
"Content-Disposition": "form-data; name=PdfFile; filename=\"@{variables('pdfFileName')}\"",
"Content-Type": "application/pdf"
}
},
{
"body": "param1Value",
"headers": {
"Content-Disposition": "form-data; name=param1Name"
}
},
...
}
Method #2: Manually build body with boundary separators
Result: pdf file was accepted by API but all pages are blank
Code:
"headers": { "Content-Type": "multipart/form-data; boundary=--[my boundary string]", ...},
"body": "--[my boundary string]\r\nContent-Disposition: form-data; name=PdfFile; filename=\"@{variables('pdfFileName')}\"\r\nContent-Type: application/pdf\r\n\r\n \r@{body('Get_blob_content')}\n\r\n--[my boundary string]\r\nContent-Disposition: form-data; name=\"param1Name\"\r\n\r\n\r\n--[my boundary string]--",
I compared the file content from the original file and Logic App activity raw inputs, there is difference and I don't know how it affects the result.
**Original file: **
... stream\nxœì} @TG×öÜ»…²”¥7‘…¥×¥ ¨À ‚ ‚T lô¢K P¬ ±c,±wQ Kl X°kÔØb Æ c4šh [b‰...
Logic App activity raw inputs:
... stream\nx��}\u0007@TG��ܻ����7���ץ\t��\u0002� �T\u0005l�K\u0011P�\u0011�c,�wQ\u0013Kl\u000bX�k��b��\u0014c4�h\u0014[b�....
Also tried base64 encoding with base64 file content, it didn't work either.
Any idea will be greatly appreciated.