My Microsoft SharePains

Create a new sub site using Microsoft Flow!


Today we have seen an exciting new action added to Microsoft Flow! The action is called Send an HTTP request to SharePoint.

In this post I’m going to have a look at how to get site details out of SharePoint and after that the more exciting bit of how to create a new site. This will open many doors to site request processes in Office 365. Imagine creating a site request list, go through an approval process and create your team site all within no time at all.

Get Site details

I’m going through this step just to explain the basics.

Once you have found the Send an HTTP request to SharePoint action, all you have to do is supply the details to the REST API endpoints. Details can be found on the Microsoft Docs site.

Ok, so the Uri to be used is simply /_api/web

don’t forget to set the header to Accept=application/json;odata=verbose

Ok, this was easy. When you now look at the run output from your flow you will find ll the details of the site in json format!

Now the more exciting bit.

Creating a site

This time we need to use the POST method.

the uri now is /_api/web/webinfos/add

Then once again set the headers.



and the Body needs to be set to something like this:

{ 'parameters':
{ '__metadata':
{ 'type': 'SP.WebInfoCreationInformation' },
'Title':'My Title2',
'Description':'My Description',

The Url in the above json will be the url used within the site give in the Site Address to create a new sub site. So you would most likely use some dynamic content to set this Url.

The template I’ve set to STS#0.  This will give you a team site but of course you could select any of the other templates. But imagine creating modern team sites. Yes you can do this by just updating the WebTemplate in the above to STS (without the #0)

Do you still remember creating dictionaries in SharePoint Designer? Just to get this one call done you had to create 4 of those dictionaries. Now we’ve just just plain simple text feeding the site creation process.

Now run your flow and your site will be created!

Success Handling

When you created a site you could set a variable of the type Object to the Body that is returned by the HTTP request action. This will return something like this:

  “d”: {
    “__metadata”: {
    “Description”“My Description”,
    “Title”“My Title2”,

Error handling

When things go wrong however you need to handle things to. This starts by setting the run after settings.

Then you will get a BadGateway error returning the following json

  “error”: {
    “innerError”: {
      “message”“The Web site address \”/testsiteflow3\” is already in use.\r\nclientRequestId: 861c4a53-f91b-4945-ae71-3335403eb634\r\nserviceRequestId: 7b3e639e-70e7-5000-de78-8990577b77ff”,
      “errors”: [

Where can I use this?

Just to give you a few ideas.

At Triad I implemented some of these site creation processes in the past. But it was never this easy as it is with Microsoft Flow.