cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
allnn
New Member

Trying to add a user to the existing SharePoint group using "Send an HTTP request" and "Parse JSON" actions and getting an error on the next step

I can see that flow successfuly gets the group information I need and parses it. But when I try to use a group ID in the next "POST" Step, I get the following error:
"The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['results']' is of type 'Null'. The result must be a valid array."

 

The code for getting my SP Group information looks like this (below) and I can see it gets data from the parsing and "results" are not empty at all:
----------------------------------------------------------------------------------
{
"d": {
"results": [
{
"__metadata": {
"id": "https://xxx.sharepoint.com/sites/XYZ-EquipmentReservation/_api/Web/SiteGroups/GetById(60)",
"uri": "https://xxx.sharepoint.com/sites/XYZ-EquipmentReservation/_api/Web/SiteGroups/GetById(60)",
"type": "SP.Group"
},
"Id": 60
}
]
}
}

------------------------------------------------

 

Any ideas or if anyone resolved something similar?

 

Thank you!

 

Natalie

4 REPLIES 4
fchopo
Super User
Super User

Hi @allnn 

As I understand, you want to add a user to an existing SharePoint group. First, you get the group information, and what do you do after? Could you share a screenshot of the flow so we can help you?

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

HI fchopo,

 

Thank you for getting back to me! The error happens when I try to use the group information in the next step after the "Parse":

allnn_0-1639492469782.png

 



fchopo
Super User
Super User

Hi @allnn 

As the results variable is an array, Power Automate add automatically the apply to each action. In order to access to the id value (to use in the Send HTTP Request) you could use the following expression:

first(body('Parse_JSON')?['results'])?['id']

 which reads the first element of the array, and access to the id field. In this way, you can remove the apply-to-each, and use only the "Send HTTP..." using this expression in the ID field value.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
allnn
New Member

Hi fcholo,

 

Thank you for you suggestion and it looks really on a right way, but unfortunately it didn't work for me. For some reason script things that the 'result' package = 'Null', even though I can see, that it is not. Here is a screenshot with an error and a Parse output:

allnn_0-1639602208387.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,254)