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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

ParseJSON Failures

(0) ShareShare
ReportReport
Posted on by 18
Hello,  i have been trying to figure this out, and i am not able to find the answer anywhere.  i have an automated JSON attachment coming in every morning.  i would like to have the names on the list emailed with their results.  but i can not even get power automate to parse the JSON to even begin to figure out emailing.  i have the email being picked up by automate without issue.  it then grabs the attachment and runs it through a Compose with the following: 
 
base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes'])
 
Which this then gives me:
 
{"Document":{"name":"Research View Alerts","queries":[{"id":"5044249b-1ddc-4f1f-8bba-6065c685a71c","result":{"columns":[{"caption":"Sta3n","uniqueName":"[DimToFacility].[Sta3n]","type":null,"dataType":"BigInteger"},{"caption":"Alert Type","uniqueName":"[FactViewAlerts].[Alert Type]","type":null,"dataType":"String"},{"caption":"EmailAddress","uniqueName":"[RecipientStaff].[EmailAddress]","type":null,"dataType":"String"},{"caption":"ManagerEmail","uniqueName":"[RecipientStaff].[ManagerEmail]","type":null,"dataType":"String"},{"caption":"RecipientStaffName","uniqueName":"[RecipientStaff].[RecipientStaffName]","type":null,"dataType":"String"},{"caption":"ServiceSection","uniqueName":"[RecipientStaff].[ServiceSection]","type":null,"dataType":"String"},{"caption":"Oldest Alert Date","uniqueName":"[measures].+[120967cc-640c-464a-8d87-95028e3c52c9]","type":null,"dataType":"Double"},{"caption":"Alerts","uniqueName":"[Measures].[Alerts]","type":null,"dataType":"Double"}],"data":[["612","All","","","Smith, John","GEN MED RESEARCH","11/21/2025",7.0],["612","All","Superman@email.com","Supervisor@email.com","Kent, Clark","RESEARCH","11/22/2025",2.0],["612","All","Batman@email.com","Batmansupervisor@email.com","Wayne, Bruce","RESEARCH","11/21/2025",1.0]]}}],"tabulates":[]}}
 
which if i check the json code in another application, it states it is valid. i then generate the schema from this:
{
    "type""object",
    "properties": {
        "Document": {
            "type""object",
            "properties": {
                "name": {
                    "type""string"
                },
                "queries": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""string"
                            },
                            "result": {
                                "type""object",
                                "properties": {
                                    "columns": {
                                        "type""array",
                                        "items": {
                                            "type""object",
                                            "properties": {
                                                "caption": {
                                                    "type""string"
                                                },
                                                "uniqueName": {
                                                    "type""string"
                                                },
                                                "type": {},
                                                "dataType": {
                                                    "type""string"
                                                }
                                            },
                                            "required": [
                                                "caption",
                                                "uniqueName",
                                                "type",
                                                "dataType"
                                            ]
                                        }
                                    },
                                    "data": {
                                        "type""array",
                                        "items": {
                                            "type""array"
                                        }
                                    }
                                }
                            }
                        },
                        "required": [
                            "id",
                            "result"
                        ]
                    }
                },
                "tabulates": {
                    "type""array"
                }
            }
        }
    }
}
 
and every time i get the same failure of: The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: . Path '', line 0, position 0.'.
 
i have tried to change the "type" fields to ["string","null"] but nothing seems to be working.  any help would be great.
I have the same question (0)
  • Sam_Fawzi Profile Picture
    660 Super User 2025 Season 2 on at
    ParseJSON Failures
     
    Try to modify the input to the Parse JSON → Content use this expression:
     
    json(
    base64ToString(
    outputs('Get_Attachment_(V2)')?['body/contentBytes']
    )
    )
    let me know if that work as I did not have time to test it on my end.
  • Pstork1 Profile Picture
    68,356 Most Valuable Professional on at
    ParseJSON Failures
    I used the following schema and it worked for me based on what you posted as a sample.
     
    {
        "type": "object",
        "properties": {
            "Document": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "queries": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "result": {
                                    "type": "object",
                                    "properties": {
                                        "columns": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "caption": {
                                                        "type": "string"
                                                    },
                                                    "uniqueName": {
                                                        "type": "string"
                                                    },
                                                    "type": {},
                                                    "dataType": {
                                                        "type": "string"
                                                    }
                                                },
                                                "required": [
                                                    "caption",
                                                    "uniqueName",
                                                    "type",
                                                    "dataType"
                                                ]
                                            }
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "array"
                                            }
                                        }
                                    }
                                }
                            },
                            "required": [
                                "id",
                                "result"
                            ]
                        }
                    },
                    "tabulates": {
                        "type": "array"
                    }
                }
            }
        }
    }
     
    I'm not seeing anything different about the two schemas.  Did you make sure to do a trim on the JSON before using it?
     
    Otherwise I agree with Sam that it might be seeing the input as a string instead of actual JSON.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • AmongtheShadows Profile Picture
    18 on at
    ParseJSON Failures
    Hello, so thank you for responding, but yes i am still getting the same error, but this time it is at the compose part of it.
     
    InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'json' parameter is not valid. The provided value    (the contentBytes)  cannot be parsed: 'Unexpected character encountered while parsing value: . Path '', line 0, position 0.'. Please see https://aka.ms/logicexpressions#json for usage details.'.
     
     
  • AmongtheShadows Profile Picture
    18 on at
    ParseJSON Failures
    also i forgot to add i did try to wrap the whole expression in trim(), and still same results
  • Pstork1 Profile Picture
    68,356 Most Valuable Professional on at
    ParseJSON Failures
    Make sure you enter both the JSON() and the base64toString() using the function tab of the dynamic content dialog.  You need to use the base64toString to convert the contents to a string and then the JSON to convert that to JSON in the compose.  Then add that to the parseJSON.
     
    json(base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes']))
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
  • AmongtheShadows Profile Picture
    18 on at
    ParseJSON Failures
    Yes i tried coping directly from what you posted, and it is still creating the error at the compose. this is what i get on the Get Attachments 
     
    just throwing this out there, not sure if this is the issue, but could the file name be the issue itself?  "Research View Alerts_2025-11-24.json, could i need to remove "-" and the "_".  
  • Pstork1 Profile Picture
    68,356 Most Valuable Professional on at
    ParseJSON Failures
    try doing it in two stages.  See what you get as a result when you do the Base64ToString on the attachment Content Bytes.
    Then we can see if that needs to turned into JSON or not.  
     
    The other problem could be that the ContentBytes of the attachment will normally contain both Content and ContentType properties.  You really only want the JSON from the Content property.
     
    if this:   base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes'])
     
    gives you:
     
    {"Document":{"name":"Research View Alerts","queries":[{"id":"5044249b-1ddc-4f1f-8bba-6065c685a71c","result":{"columns":[{"caption":"Sta3n","uniqueName":"[DimToFacility].[Sta3n]","type":null,"dataType":"BigInteger"},{"caption":"Alert Type","uniqueName":"[FactViewAlerts].[Alert Type]","type":null,"dataType":"String"},{"caption":"EmailAddress","uniqueName":"[RecipientStaff].[EmailAddress]","type":null,"dataType":"String"},{"caption":"ManagerEmail","uniqueName":"[RecipientStaff].[ManagerEmail]","type":null,"dataType":"String"},{"caption":"RecipientStaffName","uniqueName":"[RecipientStaff].[RecipientStaffName]","type":null,"dataType":"String"},{"caption":"ServiceSection","uniqueName":"[RecipientStaff].[ServiceSection]","type":null,"dataType":"String"},{"caption":"Oldest Alert Date","uniqueName":"[measures].+[120967cc-640c-464a-8d87-95028e3c52c9]","type":null,"dataType":"Double"},{"caption":"Alerts","uniqueName":"[Measures].[Alerts]","type":null,"dataType":"Double"}],"data":[["612","All","","","Smith, John","GEN MED RESEARCH","11/21/2025",7.0],["612","All","Superman@email.com","Supervisor@email.com","Kent, Clark","RESEARCH","11/22/2025",2.0],["612","All","Batman@email.com","Batmansupervisor@email.com","Wayne, Bruce","RESEARCH","11/21/2025",1.0]]}}],"tabulates":[]}}
     
    Then it should work unless that's being interpreted as a string instead of JSON.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
     
  • Sam_Fawzi Profile Picture
    660 Super User 2025 Season 2 on at
    ParseJSON Failures
     
    That invisible  at the very start is a UTF-8 BOM (Byte Order Mark). In other words:
    the attachment has a hidden character at position 0,
    Try this 
     
    In Parse JSON → Content, use:
    json(
      replace(
        base64ToString(
          outputs('Get_Attachment_(V2)')?['body/contentBytes']
        ),
        '',
        ''
      )
    )
     
    hope this will help you with the issue
  • AmongtheShadows Profile Picture
    18 on at
    ParseJSON Failures
    @Sam Fawzi So i have tried your idea and i get a new error message which is the following: 
     
    i even tried splitting it in the compose and then parse json, and still get the same result:

    Compose : base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes'])

    ParseJSON : 
    json(replace(outputs('Compose'),'',''))
  • Verified answer
    Sam_Fawzi Profile Picture
    660 Super User 2025 Season 2 on at
    ParseJSON Failures
     
    lets give it one last try before  going into another route.
     
    Can you try this one for the parse Json ?
    json(
      substring(
        base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes']),
        1,
        sub(
          length(base64ToString(outputs('Get_Attachment_(V2)')?['body/contentBytes'])),
          1
        )
      )
    )
     
     
     

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 494 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 464 Moderator

#3
Expiscornovus Profile Picture

Expiscornovus 279 Most Valuable Professional

Last 30 days Overall leaderboard