Hello,
I found a resource that explains how to create a SharePoint group using Send an HTTP Request and Parse JSON.
However, when I use this, a new SP Group(s) is not created.
Any help would be appreciated.
Solved! Go to Solution.
Hi @golfnutt82,
1. To check if the SharePoint group already exists you can use a filter with the Title with a GET request. If the response is empty your group doesn't exist yet.
_api/Web/SiteGroups/?$filter=Title eq '@{variables('SharePointGroupName')}'
2. To add a user you can use a POST request against the specific site group.
Make sure you use the correct claim of the user.
_api/web/sitegroups/GetByName('@{variables('SharePointGroupName')}')/Users
{
'__metadata': {
'type': 'SP.User'
},
'LoginName': '@{variables('UserClaim')}'
}
3. When the site already has unique permissions you can use the addroleassignment method with a POST request to assign permissions to your new or existing group.
In the example below I am using contribute permission. Also make sure you use the correct principalid of the SharePoint group.
_api/web/roleAssignments/addroleassignment(principalId=@{variables('Id')}, roledefId=1073741827)
Hi @golfnutt82,
Can you switch the method from GET to POST?
I tried Post and it hung forever.
Hi @golfnutt82,
Did you try it with the same title and description in the body of the request from your first screenshot?
If so, can you try a different title (e.g. FlowGroup2)? It looks like the SharePoint group with title FlowGroup already exists (looking at the get GET response from your first screenshot).
I tried changing it to "FlowGroup1" ran it but I still dont see a created group.
I think I know what the issue but I am not sure so maybe you can clear things up for me.
Where the URI is I entered per the instruction
Because I am working from withing a sub-site having unique permissions from the parent should the URL look different? I am concerned that I created the group(s) at the top level.
Hi @golfnutt82,
You are looking at the assigned permissions. We haven't assigned any permission level (e.g. read, edit or full control) to this group yet. That is why it isn't shown in the site permissions overview.
If you want to see the group itself you could navigate to the People and Groups overview of the sub-site. That should be accessible via this url:
/sites/Test-IT/SecTest/SecTest1/_layouts/15/groups.aspx
Ahh, I see. Yes the group was created but now I want to assign the group permissions and then add users.
I appreciate your help.
I just thought of something; what if the group is already created? Can I check this condition and then just add the user to the existing group?
Hi @golfnutt82,
1. To check if the SharePoint group already exists you can use a filter with the Title with a GET request. If the response is empty your group doesn't exist yet.
_api/Web/SiteGroups/?$filter=Title eq '@{variables('SharePointGroupName')}'
2. To add a user you can use a POST request against the specific site group.
Make sure you use the correct claim of the user.
_api/web/sitegroups/GetByName('@{variables('SharePointGroupName')}')/Users
{
'__metadata': {
'type': 'SP.User'
},
'LoginName': '@{variables('UserClaim')}'
}
3. When the site already has unique permissions you can use the addroleassignment method with a POST request to assign permissions to your new or existing group.
In the example below I am using contribute permission. Also make sure you use the correct principalid of the SharePoint group.
_api/web/roleAssignments/addroleassignment(principalId=@{variables('Id')}, roledefId=1073741827)
Thank you very much for these details!
Extremely grateful for your assistance.