Name your flow and select trigger point as Manual trigger flow.
- Add action as 'Send HTTP request to SharePoint'.
- Select all configurable options as below.
Headers
1. accept
2. content-type
- application/json;odata=verbose
Body
- {
- "__metadata": {
- "type":"SP.Group"
- },
- "Title": "FlowGroup",
- "Description":"Group created from flow"
- }
Step 4
Before going to the next step, we would apply a simple trick for using data returned from the above request. Save this Flow and Run it once. Once the workflow has run successfully, go to flow history and copy the JSON response received in the above action (refer to the screenshot below). Go to the output section of the above action and copy the JSON. Keep it copied somewhere in the notepad; we will use it in the next step.
Also make sure you delete the group created, as we won't be checking condition if group exists or not.
Step 5
Add a new action, Parse JSON,
Content - Add body from dynamic content of above action
Schema - Click on 'Use sample payload to generate schema', paste the JSON copied in the previous step.
Step 6
Add a new action 'Send HTTP request to SharePoint' and configure the action as below.
We would be using the below REST API to assign permissions to group.
- /_api/web/roleassignments/addroleassignment(principalid=<GROUPID>, roledefid=1073741827)
roledefid for Permission Levels are as follows,
1073741829 - Full Control || 073741827 - Contribute || 1073741826 - Read
GroupID is the id of the group which we created from the step above. We will use dynamic content to form this URL by referencing group id.