cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nebulas
Helper I
Helper I

Help extracting values from parsed JSON - ERROR: is of type 'Null'. The result must be a valid array.

Hi there

 

I am having trouble extracting values from a JSON Response that has been parsed in PowerAutomate.

 

ERROR: 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['Contacts']' is of type 'Null'. The result must be a valid array.

 

NOTES:

My Flow Currently Looks as below:

Screen Shot 2021-06-05 at 1.54.46 pm.png

 

Here is a sample of my schema showing the 'Contacts' element:

"body": {

            "type""object",

            "properties": {

                "Id": {

                    "type""string"

                },

                "Status": {

                    "type""string"

                },

                "ProviderName": {

                    "type""string"

                },

                "DateTimeUTC": {

                    "type""string"

                },

                "Contacts": {

                    "type""array",

                    "items": {

                        "type""object",

                        "properties": {

                            "ContactID": {

                                "type""string"

                            },

                            "ContactNumber": {

                                "type""string"

                            },

                            "ContactStatus": {

                                "type""string"

                            },

                            "Name": {

                                "type""string"

                            }, ....... ETC

 

Your help would be greatly appreciated so I can figure out what I am doing wrong here.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @jinivthakkar 

 

Thanks for your response.

 

I ended up solving this by querying the JSON response through expressions without the Parse JSON action. Here is a useful video around the topic:

https://www.youtube.com/watch?v=sqx8in2PJlA

 

However for completeness I would like to understand why this was not working. I have included a single record below with test data.

Here is the output of the Parse JSON output:

{
    "body": {
        "Id": "44490428-86af-4576-ae29-e850c84e2288",
        "Status": "OK",
        "ProviderName": "Maintenance Records",
        "DateTimeUTC": "/Date(1623190657561)/",
        "Contacts": [
            {
                "ContactID": "082c9199-faf3-4d92-a0fe-377dc3deb5f5",
                "ContactNumber": "888c08cb2aa9cea8df9728f11bf8d89a606aed4f3cbb66a9eb",
                "ContactStatus": "ACTIVE",
                "Name": "John Citizen",
                "FirstName": "John",
                "LastName": "Citizen",
                "EmailAddress": "jc@email.com.au",
                "Addresses": [
                    {
                        "AddressType": "POBOX"
                    },
                    {
                        "AddressType": "STREET"
                    }
                ],
                "Phones": [
                    {
                        "PhoneType": "DDI"
                    },
                    {
                        "PhoneType": "DEFAULT"
                    },
                    {
                        "PhoneType": "FAX"
                    },
                    {
                        "PhoneType": "MOBILE"
                    }
                ],
                "UpdatedDateUTC": "/Date(1622519206660+0000)/",
                "ContactGroups": [],
                "IsSupplier": false,
                "IsCustomer": false,
                "ContactPersons": [],
                "HasAttachments": false,
                "HasValidationErrors": false
            }
        ]
    }
}

 

Thanks again!

View solution in original post

2 REPLIES 2
jinivthakkar
Super User
Super User

@Nebulas can you share the output of parse json ?

Hi @jinivthakkar 

 

Thanks for your response.

 

I ended up solving this by querying the JSON response through expressions without the Parse JSON action. Here is a useful video around the topic:

https://www.youtube.com/watch?v=sqx8in2PJlA

 

However for completeness I would like to understand why this was not working. I have included a single record below with test data.

Here is the output of the Parse JSON output:

{
    "body": {
        "Id": "44490428-86af-4576-ae29-e850c84e2288",
        "Status": "OK",
        "ProviderName": "Maintenance Records",
        "DateTimeUTC": "/Date(1623190657561)/",
        "Contacts": [
            {
                "ContactID": "082c9199-faf3-4d92-a0fe-377dc3deb5f5",
                "ContactNumber": "888c08cb2aa9cea8df9728f11bf8d89a606aed4f3cbb66a9eb",
                "ContactStatus": "ACTIVE",
                "Name": "John Citizen",
                "FirstName": "John",
                "LastName": "Citizen",
                "EmailAddress": "jc@email.com.au",
                "Addresses": [
                    {
                        "AddressType": "POBOX"
                    },
                    {
                        "AddressType": "STREET"
                    }
                ],
                "Phones": [
                    {
                        "PhoneType": "DDI"
                    },
                    {
                        "PhoneType": "DEFAULT"
                    },
                    {
                        "PhoneType": "FAX"
                    },
                    {
                        "PhoneType": "MOBILE"
                    }
                ],
                "UpdatedDateUTC": "/Date(1622519206660+0000)/",
                "ContactGroups": [],
                "IsSupplier": false,
                "IsCustomer": false,
                "ContactPersons": [],
                "HasAttachments": false,
                "HasValidationErrors": false
            }
        ]
    }
}

 

Thanks again!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,249)