Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Apply to each Expression Evaluation Failed when building string

(0) ShareShare
ReportReport
Posted on by

Apply to each Expression Evaluation Failed when building email string

Initialize varialbes: GroupID (int), strEmailRecipient (str)

1.png

Note the GroupID is used in the () to quesry the correct sitegroups and $select Email of all members. And the HTTP requests returns green.2.png

 

3.png

 

How the 'Parse JSON' step is configured:4.png

 

Which runs successfully during test:5.png

 

Here is how the 'Apply to each' is configured to build a string of email addresses:6.png

 

And the error message during test:7.png

 

I've tried adding ?[0]?['Email'] and error becomes:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@{body('Parse_JSON')?['d']?['results']}?[0]?['Email']' is of type 'String'. The result must be a valid array.

Same results when I add item()? before the email in the value 'Append to string variable'.

If only there was a step to query SPO groups for emails... but La..

Thanks in advance!

 

 

  • vnguyen1 Profile Picture
    40 on at
    Re: Apply to each Expression Evaluation Failed when building string

    @RezaDorrani 

    https://powerusers.microsoft.com/t5/Using-Flows/how-to-output-string-value-out-of-json-parse/td-p/837955

    i have looked into your solution for this flow issue. somehow i could not apply to my flow. do you have any suggestion ? please advice. Thanks

  • RezaDorrani Profile Picture
    12,141 on at
    Re: Apply to each Expression Evaluation Failed when building string

    Hi @Anonymous 

     

    Glad it worked out for you

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • Community Power Platform Member Profile Picture
    on at
    Re: Apply to each Expression Evaluation Failed when building string

    You pointed me the right direction! And my sanity thanks you @RezaDorrani!

    So I removed the parse json step.

    Added the 'apply to each' directly after the 'send an http request to SharePoint' and  

    manually added the following to the 'select an output..' through the expression builder:

     

    body('Send_an_HTTP_request_to_SharePoint')?['value']

     

    then added the following to the 'append to string variable' through the expression builder:

     

    items('Apply_to_each')?['Email']

     

    to the value and BAM! Bob's your uncle. Works like a champ.

  • RezaDorrani Profile Picture
    12,141 on at
    Re: Apply to each Expression Evaluation Failed when building string

    Hi @Anonymous 

     

    After the send an http request action which returns the users within the group

     

    Run a for loop with following expression

    body('Send_an_HTTP_request_to_SharePoint')?['value']

     

    within loop

    append to string variable

    item()?['Email']

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

     

     

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June 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 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1