Introduction
Though SharePoint online provides default access request settings to its owners and Site Sharing set to Owners and Members, one of the business organizations decided to turn off this. Since we are using Power Automate to create the sites the use case is to ‘Turn Off Access Request Settings’ and set the sharing capability to only Site Owners.
Below is the default behavior of newly created SPO sites.
Steps
This can be achieved by turning off the ‘Access Request Settings’ for the site via Power Automate. You can use the following configuration to achieve this.
Configure the ‘Send Http request to SharePoint’ according to the screenshot below.
- Site Address: Enter the Site Address where the requested access needs to be turned off
- Method: POST
- Uri:
/_api/web/SetUseAccessRequestDefaultAndUpdate(useAccessRequestDefault=@p)?@p=false
- Headers:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-HTTP-Method": "MERGE"
}
- Body: Leave as empty
Setting Sharing Permissions to only Site Owners
For this requirement, use the same ‘Send http request to SharePoint’ and configure the action as per the below screenshot.
- Site Address: Enter the site URL, where the sharing capability should be set to Site Owners only.
- Method: POST
- Uri:
_api/Web
- Headers:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-HTTP-Method": "MERGE"
}
- Headers: Enter the below json.
{
"__metadata":{"type":"SP.Web"},
"MembersCanShare": false,
"RequestAccessEmail": ""
}
Testing
Below is the screenshot of the flow.
Result
Conclusion
Thus, in this article, we have seen the following.
- Turning off access request settings for a newly created SPO site.
- And setting the site-sharing capabilities to Site Owners only.
References
- https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.web.requestaccessemail?view=sharepoint-csom
- https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245549(v=office.15)