Create a SharePoint Online Communication Site using Power Automate [Download Complete Package]

This Power Automate Flow tutorial will show us how to create a SharePoint Online communication site using Power Automate. Also, we will see how to add members to a SharePoint communication site and define the maximum storage limit and maximum storage warning limit.

Recently, I got a requirement while working for a client, to create a communication site set the storage limit, and add members to a SharePoint Online communication site.

Here we will create an Instant cloud flow, and then we will do the rest API calls to SharePoint, to create a SharePoint Online communication site. Then we will fetch the SharePoint site id to define the Storage limit and Storage warning limit, after that, we will get the group id to add the members to the SharePoint site using the rest API call.

Create a SharePoint Communication site with rest api call in Power automate
Create a SharePoint Communication site with rest api call in Power automate

Now, let’s see how we can create a SharePoint Communication site with the rest API call in Power Automate.

Download Complete Package

You can download a complete package where we have created a flow using Power Automate, where users can request a SharePoint site by filling out a form. Users will fill out a SharePoint list form by adding the below details:

  • Site Title (Single line of text)
  • Site Owner (Person)
  • Alias (Single line of text)
  • Site URL (Hyperlink)
  • Site description (Multi-line of text)
  • Site member (Person)
  • Max Storage (Number)
  • Max storage warning limit (Number)

Once the request is received, the first thing the flow will check is the site storage, if a user requested more than 50GB of storage, then it will go for approval to a concerned approver.

Else it will create a SharePoint site and send an email to the Site Owners with the Site Details.

Currently, the flow supports 3 types of sites:

  • SharePoint Online communication site
  • SharePoint Online Team site (Office 365/Microsoft 365 Group connected)
  • SharePoint Online Team site (Without Office 365/Microsoft 365 Group connected)

Create a SharePoint Online Communication Site using Power Automate

Here we will see how we can create an instant cloud flow to build a communication site in SharePoint Online using Power Automate.

Follow the below steps to create a SharePoint communication site using Power Automate.

Step 1: Create an Instant Cloud Flow

Logged in to Power Automate, and then click on + Create -> select Instant Cloud Flow.

Create a communication site in sharepoint online using flow

Then provide the Flow name, and select ‘Manually trigger Flow’ as a trigger action-> click on Create.

Create a communication site in sharepoint using flow

Now you can see the Manually trigger flow action is added to our Flow.

Create a communication site in sharepoint online using power automate

Step 2: Create a SharePoint site

See also  Power BI Donut Chart - How to use

Now we will create a SharePoint Communication site with a rest API call. So here we need the Site information to create, such as Site name, Site alias, site owners, Site member, the language of the site(for English the code is 1033), Site design id, site template(for communication site: SITEPAGEPUBLISHING#0)and ShareByEmailEnabled.

Click on the +New step-> select Compose action -> then provide the information:

  • Input: In the input field we will add an expression, to create a GUID. Every time when we run the flow it will create a new id, which we assign as the Site design id.
guid()
Create a communication site in sharepoint using power automate

So, click on the +New step -> select the action ‘Send an HTTP request to SharePoint’. Then provide the below information:

  • Site address -provide the SharePoint tenant address
  • Method- Select method as Post, we are creating the SharePoint communication site
  • Uri -We provide the ‘/_api/SPSiteManager/create’ to call the SharePoint Api endpoint.
  • Headers: Provide the headers like below:
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  • Body: Provide the essential information below to create a SharePoint communication site.
{
	"request": {
		"Title": "Nia",
		"Url": "https://tsinfotechnologies.sharepoint.com/sites/nia",
		"Description": "My Communication Site created using Power Automate flow",
		"Owner": "[email protected]",
		"Lcid": 1033,
		"WebTemplate": "SITEPAGEPUBLISHING#0",
		"SiteDesignId": "@{outputs('Compose')}",
		"ShareByEmailEnabled": true

	}
} 
create a Communication site in SharePoint Online with rest api call in Microsoft Flow

Step 3: Set the Storage limit of the SharePoint site

To set the storage limit of the SharePoint online communication site, we need the site URL and group id. For this, we will use the Parse JSON of the above output of ‘Send an HTTP request to SharePoint’, and then we will send an HTTP request to set the storage limit and storage warning limit of the SharePoint site.

So, click on the +New step -> select the Parse JSON action, and then provide the below information.

  • Content: Select the body(Send an HTTP request to SharePoint) from the dynamic content.
  • Schema: To add the schema, just click on the ‘Generate from sample’, then add the below code and click on done. Now you can see the Schema.
{
  "d": {
    "Create": {
      "__metadata": {
        "type": "Microsoft.SharePoint.Portal.SPSiteCreationResponse"
      },
      "SiteId": "ade47e06-2b50-461c-9c92-e182356de1a2",
      "SiteStatus": 2,
      "SiteUrl": "https://tsinfotechnologies.sharepoint.com/sites/nia"
    }
  }
}
create a Communication site in SharePoint Online with rest api call in Flow

Now we will set the storage limit using two parameters i.e. ‘ StorageMaximumLevel’ and ‘StorageWarningLevel’ in SharePoint rest API call.

So, click on the + New step -> then select the ‘Send an HTTP request to SharePoint‘ action, and provide the below information.

  • Site Address: Select or provide the SharePoint Admin center address
  • Method: Select POST, we are providing the storage limit.
  • Uri: Provide the Uri as ‘_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites(‘@{body(‘Parse_JSON_3’)?[‘d’]?[‘Create’]?[‘SiteId’]}’)’, we are doing API calls to that site to set the storage limit of the site.
  • Headers: Provide like the below code example (There are required while you are calling a rest API call)
{
  "Accept": "application/json;odata=nometadata",
  "Content-Type": "application/json;odata=nometadata",
  "X-HTTP-Method": "MERGE"
}
  • Body: Provide the below code example (There are required while you are calling a rest API call)to set the storage limit. Also, you can change the storage based on your requirement.
{
"StorageMaximumLevel": "80000",
"StorageWarningLevel": "62000"
}
Power Automate create a communication site in sharepoint

As, we have set the Storage limit of the SharePoint site, next we will add members to the SharePoint site.

See also  Power bi measure by category + Examples

Step 4: Add members to the SharePoint communication site

To add members to the SharePoint communication site, first, we will fetch the group id of the SharePoint site, and then by using that id we will add one member or multiple members to the SharePoint site.

Similarly, we can add Site visitors to the site by using the Site visitor group id.

So, click on the + New step, then -> select ‘Send an HTTP request to SharePoint’, to get the group id.

Then provide the below information:

  • Site Address: Select or provide the SharePoint Admin center address
  • Method: Select Get, we need to get the storage limit.
  • Uri: Provide the Uri as ‘_api/web?$select=AssociatedMemberGroup/Id&$expand=AssociatedMemberGroup’, we are doing API calls to that site to get the group id of the SharePoint site member group.
  • Headers: Provide like the below code example (There are required while you are calling a rest API call)
{
  "Accept": "application/json;odata=nometadata"
}
Power Automate create a communication site in sharepoint online

Once you get the id, to use this id we will parse json the output body of the above action ‘Send an HTTP request to SharePoint’

So, click on the +New step -> select Parse JSON action, then provide the below information:

  • Content: Select the body from the above action ‘Send an Http request to SharePoint’.
  • Schema: To get schema, click on the ‘ Generate from sample’ and then provide the below code. You see the schema is auto-generated.
{
  "AssociatedMemberGroup": {
    "Id": 5
  }
}
Power Automate create a communication site in sharepoint

Now we will add the member to the Share Point site, as we have the group id, so click on the +New step. Then select ‘Send an HTTP request to SharePoint’, action, and provide the below information.

  • Site Address: Select the Site URL -Parse json from the dynamic content.
  • Method: Select Post, we need to add the member to the SharePoint site.
  • Uri: Provide the Uri as ‘/_api/web/sitegroups/getById(5)/users’, we are doing API calls to that site to add members to the SharePoint site.
  • Headers: Provide like the below code example (There are required while you are calling a rest API call)
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  • Body: Provide the below code, where we have provided the member details to add it to the SharePoint site.
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|[email protected]"
}
Create a communication site in sharepoint online using power automate

Note:

Make sure that the SharePoint connector having the connection same as the Site owner, you have define while creating SharePoint site. To check the connector on your application, click on the More options(…) -> you can see all the connections under the My connections

Now our Flow is ready to go, so you can test the flow, and every time change the site name, and alias in Url.

See also  Power BI Line Chart Date Hierarchy [With Examples]

Step 5: Run the Flow

To run the flow, save the flow and click on the Test icon, ->Manually -> click on the Test button. Next, connect to the credential, and then click on the Continue button -> Next click on the Run Flow button -> click on Done.

You can see your Flow run successfully, we can check our flow in the Active Sites in the SharePoint admin center.

How to create a Communication site in SharePoint using Power Automate
Create a Communication site in SharePoint using Power Automate

Now you can check the Storage limit and whether Members added to the site or not.

How to create a SharePoint Online Communication site using Power Automate

Conclusion

In this Power Automate tutorial, we saw how to create a SharePoint Online Communication site using Power Automate rest API call. Also, we saw how we can set the storage limit of the site and how we can add members to the SharePoint site.

You may also like the following Power Automate tutorials:

>