How to add users to SharePoint group using Flow
In this article we will see how to add users to SharePoint group using Microsoft Flow or Microsoft Power Automate.
Let's start by having a look on the rest api to add users to SharePoint group
Rest api to add users to SharePoint group
Rest end point to add users into SharePoint group is given below
So to add users to group we need to make POST request to this endpoint and of course we need to pass user as metadata as below
Now to we know the main task, lets start creating the flow.
Create a mannually triggered Flow
In order to create a mannually triggered flow, follow below steps.
Go to https://flow.microsoft.com
Click on My flows in left section
Click new top and select Instant - from blank
Choose mannually triggred flow and click Create
At this time your flow will be created. Now lets say we know the group name and then we need to have group id in order to add user to that group
Get Group Id by Group name
Add a new step and select "Send an HTTP request to SharePoint"
Enter your site address
Choose method as GET
In URI inter below
_api/web/SiteGroups?$filter=LoginName eq 'group name'&$select=Id&$top=1
replace group name with your group here
and add two headers as below
accept : application/json;odata=verbose
content-type : application/json;odata=verbose
To get group id, We can parse the body of reponse of request we send to get the group above. but to parse the response we need to have schema and luckly we have a way to get schema.
Just run the flow once and then go to run history and click on send request to SharePoint step and it will be expanded and then copy the json body of the response and have it some where.
Now return back to flow, and add a new step and choose parse json.
In body select body from send an HTTP request to SharePoint and in schema
Click generate from sample and paste the json copied in previous step and you are done.
Add users to SharePoint group
Now we know the group id and we need to add users to SharePoint group. Lets add a new step "Send an HTTP request to SharePoint" and choose below
In Site address, enter your site address
Choose POST method
In URI enter below
Would you like to see your article here on tutorialsinhand. Join Write4Us
program by tutorialsinhand.com
Page Views : 139 Published Date :Apr 19,2020 Author :Mukesh Tiwari