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!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,407)