power automate logo

Power Automate Apply to each loop – Error Description

Examples of Power Automate loop failed error
evaluation of ‘foreach’ expression ‘@items(‘Apply_to_each’)’ is of type ‘Object’. The result must be a valid array.
or
evaluation of ‘foreach’ expression ‘@outputs(‘Get_items’)?[‘body’]’ is of type ‘Object’. The result must be a valid array.
or
it can be something else depending upon your configuration.

Apply to each loop error in power automate flow
Power Automate Apply to each failed

Cause of the issue

This can happen unexpectedly or by mistake, but mostly occurs if you have modified anything inside the loop.
The real cause of this issue is due to passing wrong value in apply to each loop. Power Automate ‘Apply_to_each’ loop requires an array of items and cannot work on Objects or any other data. So if you pass any other value than an error then the flow will fail.
In the above error, it seems that the passed value is an object and not an array. To fix this issue, pass the value parameter instead of the body parameter.

Reproduce: power automate loop error

Step 1: To reproduce the issue, create a new flow as shown below.

New flow with blank Apply to each field

Step 2: Add body instead of value

In the Apply to each block add the ‘body’ parameter instead of ‘value’

Reproduce Power Automate Apply to Each error
Choose body instead of value

Step 3: Run the flow

If you now save and run the flow, you should see the same error as displayed in the beginning.

Apply to each error reproduced in power automate flow
Apply to each error reproduced in power automate flow

Resolution: power automate loop error

To resolve the issue, as informed earlier, just change the parameter to ‘value’ instead of ‘body’. This should fix the issue. Now this will not work if you are using your own array and custom data. In that case you need to make sure that the correct array ‘value’ is passed.

Always make sure that ‘value’ is selected in ‘apply to each’ and not ‘body’

Run the flow and the apply to each should work correctly

Thank you, I hope this post has helped you to understand why power automate loop error happens and how to avoid it.

Are you trying to learn Power Apps app development? Then please check our blog posts for Power Apps tutorials.

How to Write Better Essays and Emails – Beginners Tutorial (newbietechie.com)

Please Help us Grow!

I hope you have found this article helpful. If you are happy with the document, please use the below links when you buy something from Amazon to help us grow.

Ways to Help

Amazon Affiliate Links

How this works?

Amazon affiliate program gives a small (%)share of price to the referrers, so feel free to buy anything.
Below are some Amazon affiliate links, if you open amazon application/website using these links and buy something, (it can be one of the below items or anything of your choice) Then Amazon will give us a little percentage(%) of the money you spend on Amazon. To know more check this document.

$350-Best Student laptop
Amazon In, Amazon US

$600-Work laptop
Amazon In, Amazon US

$989– High performance
Amazon In, Amazon US

Headset – $15.99
Amazon In, Amazon US

Lightspeed Mouse – $39
Amazon In, Amazon US

Keyboard – $29
Amazon In, Amazon US

The Psychology of Money
Amazon In, Amazon

Atomic Habits:
Amazon In, Amazon

Find Balance and Purpose in Life
Amazon In, Amazon

$30, Smart Watch for Smart you
Amazon In, Amazon US, Amazon UK

Work comfortably with $110
Amazon In, Amazon US, Amazon UK

Exercise at home
Amazon In, Amazon US, Amazon UK

Thank you
For your Contribution

Power Automate documentation – Power Automate | Microsoft Docs


Newbietechie.com
Author @ramizmollahmd

About Ramiz

Ramiz is a professional working in an MNC as a business and technology consultant for quite a few years now. Ramiz is proficient in various Microsoft tools and technologies. He is a tech enthusiast and an active blogger. Ramiz spends his free time playing games or watching movies. He writes blogs to share his knowledge with the world and to make it a better place to live.


Leave a Comment