Home ยป [Solved] Power Automate Apply to each loop Failed / Error [Resolved]

[Solved] Power Automate Apply to each loop Failed / Error [Resolved]

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.

How to help?

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.

Laptops & Accessories

$350-Best Daily Use Laptop
Amazon In, Amazon US, Amazon UK

$600-Work From Home laptop
Amazon In, Amazon US, Amazon UK

$949-Best entry level Gaming
Amazon In, Amazon US, Amazon UK

$9 – Ergonomic Laptop Stand
Amazon In, Amazon US, Amazon UK

$1250 – High-end Gaming Laptop
Amazon In, Amazon US, Amazon UK

For the Gamer in you

Pro Gaming Headset – $29.99
Amazon In, Amazon US, Amazon UK

Logitech G304 Lightspeed – $39
Amazon In, Amazon US, Amazon UK

Mechanical Gaming Keyboard – $99
Amazon In, Amazon US, Amazon UK

Reading is a Very Good Habit!

The Psychology of Money
Amazon In, Amazon US, Amazon UK

Atomic Habits: #bestseller
Amazon In, Amazon US, Amazon UK

Find Balance and Purpose in Life
Amazon In, Amazon US, Amazon UK

Powerful Self Help Guide
Amazon In, Amazon US, Amazon UK

Improve Business communication
Amazon In, Amazon US, Amazon UK

Famous Dale Carnegie
Amazon In, Amazon US, Amazon UK

Stay Fit, Stay Healthy

$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

More Ways to Help

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