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.
evaluation of ‘foreach’ expression ‘@outputs(‘Get_items’)?[‘body’]’ is of type ‘Object’. The result must be a valid array.
it can be something else depending upon your configuration.
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.
Step 2: Add body instead of value
In the Apply to each block add the ‘body’ parameter 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.
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.
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.
For your Contribution
Power Automate documentation – Power Automate | Microsoft Docs
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.