“My solution needs tens of SharePoint groups that I’d rather not create manually, can I use Power Automate flow to do it?”
While you should be using M365 groups instead of SP groups, it’s often hard to get rid of the SharePoint groups completely. There’re still many companies and many solutions that prefer to work with them as they’re easier to manage directly on the SharePoint site… but only if they exist. Before you can use them there’s a not-so-much-fun part – somebody must create the groups. And if there’re more than a few, it can be quite an annoying task.
Is there a way to automate creation of SharePoint groups to make the process smoother? What would it look like?
You’ll need an HTTP request
There’s no dedicated action to create a SharePoint group as Power Automate doesn’t like them, but there’s still the old approach. As many times before, there’s an HTTP request to do that from a flow.
Method: POST
Uri: _api/web/siteGroups
Headers:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
Body:
{
"__metadata": {
"type": "SP.Group"
},
"Title": "<groupName>",
"Description": "<groupDescription>"
}
Note: <…> are placeholders, replace them including the < and >.
Once the group is created you can extract its id with an expression…
body('Send_an_HTTP_request_to_SharePoint')?['d']?['Id']
…and use it to assign the group a specific permissions on the site, list/library or item, or add members to the group.
Summary
As many times before, if you know the right HTTP requests, you can automate so much more with Power Automate, even create SharePoint groups. You probably won’t need this request very often, but it comes handy if you’ve got multiple environments. Instead of using the SharePoint user interface to create the groups one by one on multiple SP sites you can have a simple flow that’ll configure the site for you. You build the flow once and reuse it anywhere – less work for you, lower risk of making a mistake.
Hi, thank you for the tutorial. Is there a way to add HTML to the group description without it getting encoded when posted?
Hello M. Webbe,
I never tried that so I can’t tell.