web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / HELP! Flow run failed!...
Power Automate
Unanswered

HELP! Flow run failed! Bad Request, Input is not valid on for each loops

(0) ShareShare
ReportReport
Posted on by 2
I've been working on this flow for days with no success so I'm turning to the Power Community.
 
My goal is when I receive a new email with attachment (export from ServiceNow), I want it to save the CSV file to my sharepoint site.
 
The flow keeps failing at the Apply to each loop.
flow.png
Categories:
I have the same question (0)
  • Mark Nanneman Profile Picture
    991 Moderator on at
    For one thing, you've got nested "Apply to each" loops (the "Apply to each" inside the "For each 1").  This is almost never what you want to do. 

    ​​​​​​​The new flow designer tends to do this automatically unfortunately, which I consider basically a bug.  So you have to be careful, I've seen it create a new loop every time I drop a dynamic reference from the same array into an action. 

    Try moving the "Apply to each" out of the "For Each 1" loop and make sure its input is the attachments array.

    If you still have trouble, post some screenshots showing your inputs for the apply to each loops, as well the references you've put into the "Get Attachment" action. 

    Also post the complete error message if it continues.

      
  • KS-27121428-0 Profile Picture
    2 on at
    Yes it's so annoying that it creates this loop and I'm still very new to this. Should I start using the old designer with future flows?
     
    I removed the loop but the error I'm getting now is "The input parameter(s) of action 'Get_Attachment_(V2)_2' contain an invalid reference to 'Get_Attachments_(V2)'. Correct to include a valid reference to 'Get_Attachments_(V2)' for the input parameter(s) of action 'Get_Attachment_(V2)_2'."
     
    Using AI, it suggested instead of using attachment ID (since it creates the loop) that I use this formula for Get Attachment (V2) 2: 
    first(body('Get_Attachments_(V2)')['value'])['Id'] 
     
    Full flow:
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 103 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 87

#3
trice602 Profile Picture

trice602 63 Super User 2026 Season 1

Last 30 days Overall leaderboard