I absolutely love SharePoint 2013 style workflows solely because of the Call Web Service action. It is hands-down one of the coolest features as it allows you to build some really amazing solutions.

I’m documenting this for my own benefit but if you happen to be in the same boat trying to build your own solution – I hope this helps!

Starting point: make sure that you have configured workflows to be able to run with elevated privileges in your site collection. Rather than re-invent the wheel, just follow this Microsoft article. From there, create a brand new Reusable workflow. The first step will be to create a variable called RESTUri of type string and have it be combining the Workflow context current site URL + /_api/web/webinfos/add. This is going to be URL that the Call Web Service will access:


Next you have a few Dictionaries to create:

1. RequestHeaders which will contain both Accept & Content-Type with the value of: application/json;odata=verbose


2. Metadata which will contain just a single entry of type as string with the value: SP.WebInfoCreationInformation

3. JSONRequest which will contain a bunch of different values:

Name Type Value
Url String This is the site name in the URL example: http://sharepoint/sites/site1/subsite (reference the list column value)
Title String The Site Title (example: Jared’s Awesome Site)
Description String The Site Description (example: Jared’s Awesome Site is a world class SharePoint blog)
Language Integer 1033 (for English, others here)
WebTemplate String STS#0 (Reference this blog for more choices)
UseUniquePermissions String true/false – if you want to inherit permissions go with false
__metadata Dictionary Workflow Variable:Metadata (defined earlier – make sure it’s a double _ underscore)


4. Params which will contain a single entry called parameters as type dictionary with the value of the JSONRequest variable.


Great! Now that you’ve set all that up, create your App Step and add a “Call Web Service” action inside of it. (If App Step is greyed out, please see here again)

You’re going to want to click on the word “this” and insert the variable RESTUri in the “Enter the HTTP web service URL” spot and then specify this as a POST method.


Click ok, then click on the word “request” and select the Params variable you had created. Your call web service action should look like this now:


Now, right click on the call web service action and click the properties button. Map the RequestHeaders to the variable you’d created, create a new dictionary called ResponseContent and map that to the ResponseContent.


Then click OK.

I like to add a step after the web service call which logs the responseCode variable to the workflow history so I know if it was successful or not. When it’s not and I’m troubleshooting, I’ll create an e-mail task which then sends me the ResponseContent so I can get more information about the error that’s being thrown.

If you’re good, go publish your workflow and click OK at the prompt about the App Step.

This is what my workflow looks like at this point:


Now go attach this new workflow to your list which should have columns for: Title, Description, and URL.

One other fun little tidbit which I’ll give thanks to Fabian Williams for is that the AppStep can be a little tricky. If your workflow is throwing “Unauthorized” errors, check out Fabian’s blog post.


2 thoughts on “Creating subsites using REST API from SharePoint Designer Workflow

  1. Thank so much for this post. It’s great. I try so many sites in the Internet without success. The reason was, that nobody write the note that it’s important to make sure it’s a double underscore in metadata!!! I wrote always one underscore 😦
    I’m so happy! Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s