I'm trying to create a Power Automate Flow in cloud that sends a PDF to Mulesoft's IDP. I already created a document action on Mulesoft's site so I have the POST URI ready to go.
For some reason, when I try to create an HTTP that sends the PDF to IDP, I keep getting error messages. Basically, the set up is to trigger when my bot email address receives an email with the PDF and specific subject line. Then it triggers the "For Each Attachment" loop (see code below - I edited out my authentication and URI details)
The main error I'm getting right now is
Unable to process template language expressions in action 'HTTP_-_Post_Doc_1' inputs at line '0' and column '0': 'The template language function 'base64ToBinary' expects its parameter to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#base64ToBinary for usage details.'.
I've tried searching online and ChatGPT for solutions, but nothing is working, and seems no one has made a video showing how to combine Power Automate and Mulesoft IDP yet. Any guidance would be appreciated!! Thank you!
"type": "Foreach",
"foreach": "@triggerOutputs()?['body/attachments']",
"actions": {
"Condition": {
"type": "If",
"expression": {
"and": [
{
"contains": [
"@item()?['name']",
".PDF"
]
},
{
"equals": [
"@item()?['isInline']",
false
]
}
]
},
"actions": {
"Get_attachment_content": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"messageId": "@triggerOutputs()?['body/id']",
"attachmentId": "@item()?['id']"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
"connection": "shared_office365-1",
"operationId": "GetAttachment_V2"
}
}
},
"HTTP_-_Post_Doc_1": {
"type": "Http",
"inputs": {
"uri": "https://idp-rt.us-east-1.anypoint.mulesoft.com/api/v1/organizations/...",
"method": "POST",
"headers": {
"Content-Type": "multipart/form-data; boundary=boundary_123456"
},
"body": "--boundary_123456\nContent-Disposition: form-data; name=\"file\"; filename=\"@{item()?['name']}\"\nContent-Type: application/pdf\n\n@{base64ToBinary(coalesce(body('Get_attachment_content')?['$content'], body('Get_attachment_content'), item()?['contentBytes']))}\n--boundary_123456--",
"authentication": {
"type": "Basic",
"username": "...",
"password": "..."
}
},
"runAfter": {
"Get_attachment_content": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
},
"secureData": {
"properties": [
"inputs",
"outputs"
]
}
}
}
},
"else": {
"actions": {}
}
}
},
"runAfter": {}
}
I'm not an API expert so just in case others find it helpful here is more information regarding the API's POST information

coalescemight be ok but it’s settling on something that’s not a string. Can you show us the runtime data of the data being passed to the coalesce?