cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dotty
Level: Powered On

Apply to each Expression Evaluation Failed when building string

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!

 

 

3 REPLIES 3
Dual Super User
Dual Super User

Re: Apply to each Expression Evaluation Failed when building string

Hi @Dotty 

 

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

 

 

 

Highlighted
Dotty
Level: Powered On

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.

Dual Super User
Dual Super User

Re: Apply to each Expression Evaluation Failed when building string

Hi @Dotty 

 

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 175 members 6,008 guests
Please welcome our newest community members: