Is it possible to add an existing SharePoint group to a SharePoint site via SharePoint request action in Power Automate [or alternatively SP REST API]?
I have only seen how to create a new group and add it to a site.
Is it possible to add an existing SharePoint group to a SharePoint site via SharePoint request action in Power Automate [or alternatively SP REST API]?
I have only seen how to create a new group and add it to a site.
You can assign permissions to SharePoint group using SharePoint REST API like:
function setPermissionForGroup(){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/roleassignments/addroleassignment(principalid=<GroupId>, roledefid=1073741827)",
type: "POST",
contentType: "application/json;odata=verbose",
headers: { "Accept": "application/json; odata=verbose","X-RequestDigest": $("#__REQUESTDIGEST").val(),"X-HTTP-Method": "POST" },
success: function (data) {
alert('Contribute permission set on group');
},
error: function (data) {
alert("Error: " + JSON.stringify(data));
}
});
});
Replace <GroupId>
with the ID of SharePoint group. Open the SharePoint group & you will find the group ID in browser URL:
roledefid
for Permission Levels are as follows:
You need to convert above REST call in Power Automate Send an HTTP request to SharePoint action.
If the group doesnot exist on the site, you could use the EnsureUser method to add the group to a site: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245233(v=office.15)?redirectedfrom=MSDN
http://<sitecollection>/<site>/_api/web/ensureUser(logonName)