web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / 'Send_an_HTTP_request'...
Power Automate
Answered

'Send_an_HTTP_request' failed (possibly) because of "attachments" property

(0) ShareShare
ReportReport
Posted on by 72
Hi Everyone,
 
I created a flow to get an XLSX file from a OneDrive folder, and use it as an attachment.
 
I save the attachment details in a JSON variable named fileAttachment (as follows) to use in my HTTP call:
 
{
"name": "Monthly Report-Windows.xlsx",
"contentBytes": "<base64(content Bytes)>",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
 
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.
Categories:
I have the same question (0)
  • Suggested answer
    Ellis Karim Profile Picture
    11,990 Super User 2026 Season 1 on at
    Hi @tolga-balci​​​​​​​
     
    Try the following for the attachment array:
     
     
    {
      "name": "Monthly Report-Windows.xlsx",
      "contentBytes": {
        "$content-type": "<contentType>",
        "$content": "<content>"
      }
    }
     

     

    Ellis Karim
    Ellis Karim



    ​​​​​​​
  • Verified answer
    tolga-balci Profile Picture
    72 on at
     
    Thanks very much for your reply, but unfortunately I could not get your solution to work.
     
    However, I found out the time (after a week) to create a solution.
     
    In my initial post:
    1. I converted the attachment contentBytes to <base64>. It was wrong. I converted it to @body('<name>')['$content']. 
    2. "contentType" property under "body" was missing. I added it.
    3. "importance" property was missing, I added this one as well.
    I did not check if any of those are required attributes for a successful HTML call, causing an error.
     
    For anyone who needs a tl;dr answer, below is a template that you can use:
     
    {
        "subject":"",
        "importance":"",
        "body":{
            "contentType":"HTML",
            "content":""
        },
        "toRecipients":[
            {
                "emailAddress":{
                    "address":""
                }
            }
        ],
        "ccRecipients":[
            {
                "emailAddress":{
                    "address":""
                }
            }
        ], "attachments":[{
    "@odata.type": "#microsoft.graph.fileAttachment",
    "name": "",
    "contentBytes": ""
    }]
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard