The initial body
as part of the inputs
seems off to me, unless your API is looking for $multipart
parameter as part of the request. I suggest using a tool like Fiddler to observe how the traffic from the request is hitting your API. Also review Create a custom connector from a Postman collection | Microsoft Learn if you haven't done so already. Use Postman to draft your request and import the request to your custom connector. I think this will give you a better framework to craft your connection. I don't see anything wrong with @body('Get_blob_content_(V2)')
but just in case, you can also append .value()
to be more explicit if you're not seeing contents in the Fiddler trace.
How to upload a file through my Api connector using multipart/form-data request in Logic App?
Hi,
I have a custom Api connector that I am trying to use in a Logic App to upload a *.mpp file into my endpoint. I keep getting an internal 500 error when submitting my PUT request.
To explain my Logic App, I have a reoccurrence trigger that is followed by an action to get the file content from my *.mpp file in OneDrive. Then, that content is stored in a temporary blob. Followed by the get blob content action so I can input that into my API. (I saw a lot of people used temporary blobs for file uploads)
I have ensured that the file can upload, I know I also noticed that some characters were corrupted so I had to mess around to fix that issue to preserve data. So, I'm really stuck on how to pass this file in my multipart/form-data request.
My API is using a multipart/form-data content type for the upload. Here's a snippet of my PUT request in my Logic App. I would love to use a connector rather than just using individual http actions in my app since I'm using OAuth credentials that utilize refresh tokens.
{
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['Name_of_Connection']['connectionId']"
}
},
"method": "put",
"headers": {
"Company-Id": 00000
},
"path": "/rest/v1.0/schedule_integration",
"queries": {
"project_id": 00000
},
"body": {
"$content-type": "multipart/form-data",
"$multipart": [
{
"headers": {
"Content-Disposition": "form-data; name=\"schedule_integration\"; filename=\"file.mpp\""
},
"body": "@body('Get_blob_content_(V2)')"
}
]
}
},
"operationOptions": "DisableAsyncPattern",
"runtimeConfiguration": {
"staticResult": {
"name": "name",
"staticResultOptions": "Disabled"
}
}
}
Azure Logic Apps
1 answer
Sort by: Most helpful
-
Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
2023-06-30T16:49:24.2933333+00:00