cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User III
Super User III

Re: 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."

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




Highlighted
Frequent Visitor

Re: 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 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

Highlighted
Super User III
Super User III

Re: 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."

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




Highlighted
Frequent Visitor

Re: 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."

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (9,765)