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
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
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":
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
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:
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
User | Count |
---|---|
75 | |
21 | |
18 | |
17 | |
13 |
User | Count |
---|---|
127 | |
35 | |
31 | |
28 | |
25 |