web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trying to add a user t...
Power Automate
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 4

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

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at

    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

  • allnn Profile Picture
    4 on at

    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 Profile Picture
    8,003 Moderator on at

    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

  • allnn Profile Picture
    4 on at

    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

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard