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

Notifications

Announcements

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 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Expiscornovus Profile Picture

Expiscornovus 185 Most Valuable Professional

#2
harshdeol Profile Picture

harshdeol 167 Moderator

#3
S-Venkadesh Profile Picture

S-Venkadesh 159 Moderator

Last 30 days Overall leaderboard