Configure SharePoint Site Settings Using Power Automate

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.

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.

Send Http request

  1. Site Address: Enter the Site Address where the requested access needs to be turned off
  2. Method: POST
  3. Uri:
    /_api/web/SetUseAccessRequestDefaultAndUpdate(useAccessRequestDefault=@p)?@p=false
  4. Headers:
    {
      "accept": "application/json;odata=verbose",
      "content-type": "application/json;odata=verbose",
      "X-HTTP-Method": "MERGE"
    }
  5. 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.

Sharing Permissions

  1. Site Address: Enter the site URL, where the sharing capability should be set to Site Owners only.
  2. Method: POST
  3. Uri:
    _api/Web
  4. Headers:
    {
      "accept": "application/json;odata=verbose",
      "content-type": "application/json;odata=verbose",
      "X-HTTP-Method": "MERGE"
    }
  5. Headers: Enter the below json.
    {
      "__metadata":{"type":"SP.Web"},
      "MembersCanShare": false,
      "RequestAccessEmail": "" 
    }

Testing

Below is the screenshot of the flow.

Testing

Result

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

  1. https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.web.requestaccessemail?view=sharepoint-csom
  2. https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245549(v=office.15)