I created a flow to get an XLSX file from a OneDrive folder, and use it as an attachment.
I'm then using the following HTTP call - the Content-Type is set to application/json:
{
"subject": "Here is your monthly report",
"body": {
"content": "Here is your monthly Windows report as requested."
},
"toRecipients": [
{
"emailAddress": {
"address": "customer_to@customer.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "customer_cc@customer.com"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "variables('fileAttachment')?['name']",
"contentType": "variables('fileAttachment')?['contentType']",
"contentBytes": "variables('fileAttachment')?['contentBytes']"
}
]
}
This HTTP call returns the following error:
{
"error": {
"code": "BadRequest",
"message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
"innerError": {
"date": "2025-01-23T13:26:54",
"request-id": "",
"client-request-id": ""
}
}
}
However, if I take out the "attachments" property from the call, the HTTP call works perfectly. Following is the JSON that works without any issues:
{
"subject": "Here is your monthly report",
"body": {
"content": "Here is your monthly Windows report as requested."
},
"toRecipients": [
{
"emailAddress": {
"address": "customer_to@customer.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "customer_cc@customer.com"
}
}
]
}
That means, the code that is causing the error is with the "attachments" property. I've run the JSON call through various linters, and there is no issue with the JSON structure.
I'm trying to understand what causes the error, but unfortunately no luck so far.
Any ideas?
Thanks!
Tolga
Edit: Formatted code.