cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerapps_2020_
Frequent Visitor

Apply to each error when parsing JSON - "the result of the evaluation of 'foreach' expression '@items('Apply_to_each_2')?['products']' is of type 'Null'. The result must be a valid array."

I'm parsing a JSON using flow to create records in D365 for Finance and Operations. I have nested "apply to each" statements to read through each object in the JSON. Currently, this Flow successfully creates all of the records in the JSON, but errors saying that I'm getting a null value. Anyone have thoughts on potential fixes? I've tried recreating this Flow to see if it's just an issue with a designer, but keep getting this same error.

 

 

 
 

2020-02-18 12_04_27-Edit your flow _ Power Automate.png2020-02-18 12_05_31-Run History _ Power Automate.png

4 REPLIES 4
Jcook
Super User
Super User

Hello @powerapps_2020_ 

In your run that you posted,

What does the Parse JSON action look like?

 

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





 

I'm taking in a file from OneDrive, and just have my schema. Could it be the schema that needs updating? This is the first time I'm working with JSON files, so I'm not sure what I could be missing from that aspect.

2020-02-18 15_13_08-Run History _ Power Automate.png

Hello @powerapps_2020_ 

 

Yes this seems to be a issue with your JSON

 

Try and update. You could try to add a Compose action and use the json() expression.

Than use a Parse JSON on the outputs of the Compose

 

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





powerapps_2020_
Frequent Visitor

As a follow-up: this error occurred because the JSON has multiple objects, some with nested objects (i.e., the JSON has a hierarchical structure). Initially, I used the parse JSON task to read the file, and the flow would successfully create the records, but would give errors saying that the last object in the file, "products," is null.

 

I was ultimately able to get this flow to work by just placing a condition to proceed with creating the record if products is not null.

 

 2020-02-20 08_24_23-Edit your flow _ Power Automate.png

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!

Users online (1,192)