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 / Flow Failure- The exec...
Power Automate
Suggested Answer

Flow Failure- The execution of template action 'Apply_to_each' failed

(0) ShareShare
ReportReport
Posted on by 2
 
Hi all, this has been a problem flow for months. It did work before= The flow things the array is a string when its set as an array. The goal is to take MS form responses which include file uploads and send those to an email address once the form is submitted. The form and files are located in a sharepoint site.
 
Error Message: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression ' @{variables('FileAttachments')}' is of type 'String'. The result must be a valid array.
 
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,499 Super User 2026 Season 1 on at
    Based on what I see, it appears you are trying to get the attachments from a Microsoft Forms response? I am surprised this was working for you as the response ID in the get file content is not the identifier of the file it is the ID of the response from the trigger.
     
    You need to use a Parse JSON action on the question that contains the attachments. You can use the following for the scheme:
     
    {
        "type""array",
        "items": {
            "type""object",
            "properties": {
                "name": {
                    "type""string"
                },
                "link": {
                    "type""string"
                },
                "id": {
                    "type""string"
                },
                "type": {},
                "size": {
                    "type""integer"
                },
                "referenceId": {
                    "type""string"
                },
                "driveId": {
                    "type""string"
                },
                "status": {
                    "type""integer"
                },
                "uploadSessionUrl": {}
            },
            "required": [
                "name",
                "link",
                "id",
                "type",
                "size",
                "referenceId",
                "driveId",
                "status",
                "uploadSessionUrl"
            ]
        }
    }
     
     
    Follow the Parse JSON action with an apply to each action and use the Body value from the Parse JSON action for the output from previous step field.
     
    Then use id value from the Parse JSON action to get the file. Although, you said you are using SharePoint to store the MS Form. I've only done this when the form is Stored in OneDrive. Therefore, some of these steps may need to change. But this is what it looks like in my flow with a few other actions that are not relevant to your needs but are to my process.
     
    The condition is optional. I found sometimes people were able to upload zero-byte files and it caused the flow to fail. So I check that the file size is more than 0.

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 957

#2
Valantis Profile Picture

Valantis 847

#3
Haque Profile Picture

Haque 609

Last 30 days Overall leaderboard