Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Apply to each failed with json

(1) ShareShare
ReportReport
Posted on by 8
Error message: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@json(outputs('Get_response_details')?['body/rd38acc3920934e11a5b50e4bf7a65c47'])' is of type 'Null'. The result must be a valid array.
 
This is LITERALLY a copy of another flow with the exact same functions and works just fine. In fact it worked this morning and then all of a sudden failed...HELP?
 
The failure...
 
  
 
 
json(outputs('Get_response_details')?['body/rd38acc3920934e11a5b50e4bf7a65c47'])
 
 
 
The one that works...
 
 
json(outputs('Get_response_details')?['body/r271bcadc630a4786a9125481e54b0ead'])
  • Suggested answer
    NsL Coder Profile Picture
    469 Super User 2025 Season 1 on at
    Apply to each failed with json
    I see a lot of issues...
    • Let's start from the end.. your send email did not have any attachment added to it, then of course there's no attachment
    • you are applying to each of the file uploaded, adding it to GapReports arrray variable. Then loop GapReports to get file content. makes no sense why you try to do this. just loop the file uploaded
    • you are then appending the file name and content to the same GapReports array variable,
    There is a logic error in what you trying to do.
     
    Do this instead:
    1. condition on the file upload question being not null
      • if yes - not null
        • Parse JSON of the file upload question (no need to put the file upload question dynamic content in a json() expression)
        • Apply to each - dynamic content of Parse JSON action
          • get file content
          • append to GapReports with the file name and content
    2. add the GapReports array variable into your Send Email Attachment section (after clicking on the T looking icon at the upper-right corner of the attachment section)
  • BH-30071548-0 Profile Picture
    8 on at
    Apply to each failed with json
    The flow appears to be working now but It is not attaching the uploaded file to email. I appear to be missing a step...
     
     
     
     
  • abm abm Profile Picture
    32,472 Most Valuable Professional on at
    Apply to each failed with json
    Hi
     
    Believe the response details you are trying to convert to json is the file upload?
     
    Try to do a empty() expression is equal to false
     
    empty(outputs('Get_response_details')?['body/r271bcadc630a4786a9125481e54b0ead']) == false then under the 'Yes' condition use the Get file content action step.
     
     
    Thanks
  • BH-30071548-0 Profile Picture
    8 on at
    Apply to each failed with json
    It is correct that I am using a non-required upload as part of the flow. I am not getting the following error when attempting the outputs function...
     
  • NsL Coder Profile Picture
    469 Super User 2025 Season 1 on at
    Apply to each failed with json
    the one that works, just means the question in the MS forms was answered, while the one that failed, the question was not answered.
     
    If you have a question that is required, then designing your flow as you screenshoted is OK.
     
    But if your question is optional and someone CAN leave it out, then your answer will be "null", and you cannot use json() expression on null. What you need to do is to use a condition action, and check if outputs('Get_response_details')?['body/rd38acc3920934e11a5b50e4bf7a65c47'] is not equals to null (null as an expression, not just type null as text), when "Yes", then do the apply to each
     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492