cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mousman85
Helper IV
Helper IV

Add specific o365 group to a SharePoint Site Permission Group

Hi,

 

I'm trying to set a flow that will create a hubsite, after the site is created, it will add a specific 365 group to the site a visitor, this group contains all our employees and gives them visitor access to every hubsite that is created (we are creating a hubsite per client and need all employee's to have access). 

 

I have the flow working with all aspects apart from being able to add a a group. I can add a specific user as a visitor that work fine. The group itself is a cloud created o365 group and the name will never change it will just be used to manage access across all the sites. I know this needs to be done with a HTTP request but i cannot work out what the body code should be to add a group and not a user. Any advice would be brilliant.


Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mousman85
Helper IV
Helper IV

I managed to solve this using the below as the setting for the Send HTTP request to sharepoint. 

Method - POST

URI - /_api/web/sitegroups(4)/users (this adds groups to the visitors sharepoint permission group)

Headers: 
accpet = application/json;odata.metadata=none
content-type = application/json;odata=verbose
{ '__metadata': { 'type': 'SP.User' }, 'LoginName': 'c:0t.c|tenant|<Group OBJECT ID>'}

 

I got the Group Object ID from Azure AD, this works for any group as long it doesn't have a another group assigned to it, so it is all users, i am using an on prem created Security Group as we wanted to only have to manage one group for giving access to all our Client Hubsites. 

 

I wanted my group added as visitors to each site that is created through Automate, so used the sitegroups(4) this seems to always be Visitors permission group for each newly created site, you can get the sitegroups number by going to Site Settings/Site Permissions - click the group you want to know the ID for and it will show the URL bar. 

 

hope this helps someone else.

View solution in original post

5 REPLIES 5
mousman85
Helper IV
Helper IV

I managed to solve this using the below as the setting for the Send HTTP request to sharepoint. 

Method - POST

URI - /_api/web/sitegroups(4)/users (this adds groups to the visitors sharepoint permission group)

Headers: 
accpet = application/json;odata.metadata=none
content-type = application/json;odata=verbose
{ '__metadata': { 'type': 'SP.User' }, 'LoginName': 'c:0t.c|tenant|<Group OBJECT ID>'}

 

I got the Group Object ID from Azure AD, this works for any group as long it doesn't have a another group assigned to it, so it is all users, i am using an on prem created Security Group as we wanted to only have to manage one group for giving access to all our Client Hubsites. 

 

I wanted my group added as visitors to each site that is created through Automate, so used the sitegroups(4) this seems to always be Visitors permission group for each newly created site, you can get the sitegroups number by going to Site Settings/Site Permissions - click the group you want to know the ID for and it will show the URL bar. 

 

hope this helps someone else.

Thank you for your detailed response.

sparipal
Frequent Visitor

can anyone help me , I have same requirement and followed same steps as mentioned above but getting error.

"User doesn't exists or not unique"

dennisb88
Responsive Resident
Responsive Resident

Hi @sparipal ,

 

I had the same issue. Above works fine if you've a security group.

When you try to add an Office 365 group (like me), then you should use:

c:0o.c|federateddirectoryclaimprovider|

 

dennisb88_0-1631986633125.png

Hope it will help you

 

Regards,

Dennis.

sparipal
Frequent Visitor

Hello Dennis,

 

I tried it and it worked thank you so much

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,865)