I am trying to use “Send an HTTP Request” in Power Automate to create a draft email. I want it to:
-
Include text in the body
-
Add recipients in CC
This works fine when I don’t include an attachment or when there are CC recipients.
However, when I try to add a DOCX attachment, I get a Bad Request / error. I have tried setting Content-Type to application/json and using Base64 encoding for the file content, but nothing seems to work.
I can show an example of the code that works and the code that fails.
Could someone advise:
-
Why adding a DOCX attachment causes this error
-
How I can fix it so I can create draft emails with attachments
Thanks in advance!
This code works:
{
"subject": "Reminder: Uren niet ingevuld",
"importance": "normal",
"body": {
"contentType": "html",
"content": "<p>Beste @{outputs('Naam_voor_aanmaning')},"
},
"toRecipients": [
{
"emailAddress": {
"address": "@{outputs('Compose_8')}"
}
}
]
}
this code does not work:
{
"subject": "Reminder: Uren niet ingevuld",
"importance": "normal",
"body": {
"contentType": "html",
"content": "<p>Hi Nalie,"
},
"toRecipients": [
{
"emailAddress": {
"address": "a@st.nl"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "voorbeeld.docx",
"contentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"contentBytes": "@{base64(body('Get_file_content_using_path'))}"
}
]
}
btw i tried also only dynamic file content and also without "@" and without base 64 just nothing works