skip to Main Content

Exploring Creating SharePoint TeamSites Using SiteDesign and the REST API

Time to read: 3 minutes By Kevin McDonnell, Senior Technical Architect 

I have been recently exploring creating sites with Flow off the back of a list. I had done this previously with Azure Functions very successfully but wanted to see if Site Scripts and Site Designs could remove that extra step. In short: Yes you can!

There are some great posts on creating Site Scripts and Site Designs (see additional links at the bottom of the page) but the basic one on Microsoft Docs gets things going pretty quickly.

So how does Flow create the site? Creation of a Team Site using REST does not appear to be that well documented and I couldn’t find any examples of creating a site with a site design in one step. This was a little odd, so I took a look at what calls the main SharePoint page uses to create a site and the key appeared to be:

_api/GroupSiteManager/CreateGroupEx

(Massive caveat here – as these APIs appear to be minimally documented they may be subject to change at short notice.)

There are a few examples of using this out there (try searching CreateGroupEx) that allowed you to pass the DisplayName, the Alias, whether it is public and even some that covered classification. However, I couldn’t find any that passed anything to set the Site Design ID. Thankfully, I was able to find that it was passing the JSON below.

{ "displayName":"@{triggerBody()?['Title']}",
"alias":"[email protected]{triggerBody()?['ID']}", "isPublic":false,
"optionalParams":{ "Description":"",
"CreationOptions":["implicit_formula_292aa8a00786498a87a5ca52d9f4214a_03dac6d2-3e91-4f43-9163-
953ce1bf7616}"]
} }

A little bit of time later I realised that the later half of the implicit_formula section was in fact the Guid of the Site Design. Once I had this I was away and running.

Exploring Creating SharePoint TeamSites Using SiteDesign and the REST API | New item

I created a Flow that triggered from a SharePoint list containing the list of projects. It first retrieved the list of Site Designs to get the Guid – I could have hardcoded this but wanted to allow it to be more user friendly and retrieved by name, matching what the user would do. It then iterates through the designs until it found the matching one and made the call to CreateGroupEx.

Exploring Creating SharePoint TeamSites Using SiteDesign and the REST API | Apply to eachThe REST API calls were made using the relatively recent SharePoint activity called “Send an HTTP request to SharePoint” which meant that there was no need to work with any tokens or credentials.

There are still many cases where you would need some additional scripting that would require the PnP provisioning templates for more advanced scenarios and so would use an Azure Function, but for situations where you do not want to have to have an Azure subscription then this is a good alternative. Chris O’Brien covers some great scenarios in his SharePoint Nuts and Bolts post below.

Happy site creating (but don’t forget the governance…)!

By Kevin McDonnell, Senior Technical Architect at Ballard Chalmers

About the author

Kevin McDonnell is a respected Senior Technical Architect at Ballard Chalmers, With a Master of Engineering (MEng), Engineering Science degree from the University of Oxford he specialises in .NET, Azure, the Office 365 development suite and has a broad understanding of the wider Microsoft stack. He listens to what clients are looking to achieve and helps identify the best platform and solution to deliver on that. Kevin regularly blogs on Digital Workplace topics and is a regular contributor to the monthly #CollabTalk discussions on Twitter.

 


 

Post Terms: Cloud | Enterprise Applications | Enterprise Software | intranet | Mictosoft Teams | sharepoint | Software

About the Author

BC Technical Team

Our technical team contribute with blogs from their respective specialities, be that Azure, SQL, BizTalk, SharePoint, Xamarin and more. From the lead architect to developers and testers, each person provides content straight from their experience.

Back To Top