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 : +nDsHWjTHNHT7xb4E30on/
Power Automate - Building Flows
Unanswered

For Each Error: expression '@body('Parse_JSON')?['alerts']' is of type 'Null'. The result must be a valid array.

Like (0) ShareShare
ReportReport
Posted on 19 Jan 2024 21:12:48 by

Hi there,

 

My goal is to parse a blob file as it is added to a storage account, then alert if the value of 

@body('Parse_JSON')?['alerts']['items']['riskdesc'] meets a certain criteria . However, I cannot get past the error message above when trying to select a specific value from the JSON object.

 

Per the references below, I have tried converting the object by using the Initialize Variable, Compose, and Select operations, both inside and outside of a For Each Loop.  

 

Sample of Parse JSON schema:

 

 

 

 

{
 "properties": {
 ......
 },
 "alerts": {
 "items": {
 "properties": {
 ......
 "riskdesc": {
 "type": [
 "string",
 "null"
 ]
 },
 ......
 },
 "type": "array"
 },
 "type": "array"
 }
 },
 "type": "object"
}

 

 

I have attached screenshots of the flow and my most recent run logic. 

 

Please let me know if I can clarify anything here. Any help would be greatly appreciated!

 

References: 

https://powerusers.microsoft.com/t5/Building-Flows/Apply-to-each-error-results-is-of-type-Null-The-result-must-be-a/m-p/1896604#M208912

https://pacodelacruzag.wordpress.com/2017/05/18/transforming-json-objects-in-logic-apps/

 

  • eliotcole Profile Picture
    4,266 Moderator on 22 Jan 2024 at 19:33:08
    Re: For Each Error: expression '@body('Parse_JSON')?['alerts']' is of type 'Null'. The result must be a valid array.

    You could probably just grab the alerts directly without using the parseJson action, @Anonymous 🙂 ... not going to get deeply into here, but you could try something like the following wherever it is needed.

     

    Just use the name of whatever action you have the Parse JSON action running off of and you will possibly get the alerts:

    @body('NAME_OF_THE_ACTION_THAT_PARSE_JSON_IS_FEEDING_FROM')?['alerts']

    Obviously I don't know the action name, and I cannot download files to look at them (always good to embed screenshots), but yeah ... it might be easier here. If you are going to type the action name in there yourself, just remember to use underscores where the spaces are.

     

    So 'Get items' becomes 'Get_items' ... etc.

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on 22 Jan 2024 at 19:25:40
    Re: For Each Error: expression '@body('Parse_JSON')?['alerts']' is of type 'Null'. The result must be a valid array.

    You want to access „@body('Parse_JSON')?['alerts']…“

     

    As you can see from your previous post „alerts“ is inside of a „site“ array. The parse json scheme you provided doesn’t show that so how did you create it or what are you parsing.

     

    The dynamic content from parse json doesn’t care about the actual content. In fact it doesn’t know it. It just provides it because you provide a schema.

  • Community Power Platform Member Profile Picture
    on 22 Jan 2024 at 18:46:36
    Re: For Each Error: expression '@body('Parse_JSON')?['alerts']' is of type 'Null'. The result must be a valid array.

    Hi @Matthy79,

     

    Thank you for checking this out and proving the coalesce suggestion. I will try this next. However, "alerts" is definitely in the provided JSON. It also suggests it as dynamic content under the Parse JSON step. Maybe I am just accessing it incorrectly? 

     

    Screenshot_1.png

     

    This is a snippet of one the of entries that the LA is parsing:

    {
    	"@programName": "ZAP",
    	"@version": "2.14.0",
    	"@generated": "Thu, 2 Nov 2023 21:15:24",
    	"site": [
    		{
    			"@name": "*********************",
    			"@host": "*********************",
    			"@port": "443",
    			"@ssl": "true",
    			"alerts": [
    				{
    					"pluginid": "10202",
    					"alertRef": "10202",
    					"alert": "Absence of Anti-CSRF Tokens",
    					"name": "Absence of Anti-CSRF Tokens",
    					"riskcode": "2",
    					"confidence": "1",
    					"riskdesc": "Medium (Low)",
    					"desc": "",
    					"instances": [
    						{
    							"uri": "*********************",
    							"method": "GET",
    							"param": "",
    							"attack": "",
    							"evidence": "",
    							"otherinfo": ""
    						}
    					],
    					"count": "9",
    					"solution": "",
    					"otherinfo": "",
    					"reference": "",
    					"cweid": "352",
    					"wascid": "9",
    					"sourceid": "50"
    				}
    			]
    		}
    	]
    }

     

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on 20 Jan 2024 at 16:33:03
    Re: For Each Error: expression '@body('Parse_JSON')?['alerts']' is of type 'Null'. The result must be a valid array.

    It looks like „alerts“ is not part of the JSON you received. Have you checked that? If it is sometimes there and sometimes not you can use coalesce.

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete