Changing a site’s master page using REST via SharePoint Designer Workflow

As a follow-on to my previous post about how to create subsites using the SharePoint REST API, I encountered a scenario where a customized master page was already in existence and I needed to apply that to subsites created with my provisioning workflow.

<insert quick note about Microsoft Patterns & Practices>
Microsoft’s Patterns & Practices are awesome as they provide you with prescriptive guidance for how to customize SharePoint without encountering future collisions with the product team’s development path. However, there may be times where you deviate from that guidance (such as not touching the master page) and require a solution for changing the master page.
</end PNP guidance>

So, let’s get down to business.. You’re going to want to build a few dictionary variables:

1. MetadataMasterPage

Name Type Value
type String SP.Web

2. RequestHeadersMasterPage

Name Type Value
accept String application/json;odata=verbose
content-type String application/json;odata=verbose
X-HTTP-Method String MERGE
IF-MATCH String *

3. JSONMasterPage

Name Type Value
__metadata Dictionary Variable:MetaDataMasterPage
MasterUrl String /sites/yoursite/_catalogs/masterpage/oslo.master
CustomMasterUrl String /sites/yoursite/_catalogs/masterpage/oslo.master

*Now clearly you wouldn’t always point your MasterUrl & CustomMasterUrl to oslo, this is just an example. You would provide the actual path to the master page you are setting.

Another point – there’s two master pages – the Site Master & System Master. See the image below to figure out which one is which:

(Also note – you have to include both in your dictionary variable even if you’re just setting one to a different value)


Now all you have to do is create an App Step and include a “Call HTTP web service action” within it.

The URL is going to be: http://pathtotheURL/_api/web and the HTTP method will be POST.


Click the OK button, then right click the workflow action and select properties.

1. RequestHeaders = Variable:RequestHeadersMasterPage
2. RequestContent = JSONMasterPage
3. ResponseHeaders = new Dictionary, call is ResponseHeadersMasterPage


That’s it! Go ahead and run your workflow and behold the power of the SharePoint REST API. It’s awesome! 🙂

Here’s what the full workflow looks like with my URL blurred out:



8 comments on “Changing a site’s master page using REST via SharePoint Designer Workflow”
  1. Tim says:

    I keep getting “BadRequest” when i attempt to run this workflow.

    I’ve wondered if my issue is related to targeting the MasterURL and CustomURL as i am on the root of the site collection. I figured I did not need to add “/sites/yoursite/” before “/_catalogs/masterpage/oslo.master”. If i did need to add it, i couldn’t determine what to use for “yoursite”

    I’ve also fooled around some with the App Step permissions but no luck getting a different response.

    1. Hi Tim, if it’s a root site collection then you are correct you won’t need to add the /sites/yoursite info. For your AppStep I’m assuming you’re setting permissions as sitecollection and not sitecollection/web. Those errors are terrible – do an e-mail step after the Call web service action and have it send you the ResponseContent variable details. That will give you the real error message. If you’re following all the steps it’s probably permissions. Let me know what you find!

  2. Tim says:

    Thanks for that feedback. The response is…”The property ‘MasterURL’ does not exist on type ‘SP.Web’. I imagine that means that path to the masterpage isn’t working.

    I’m out for the weekend so i’ll dive into it again next week. If you have any thoughts that would be awesome and i really appreciate the response.

  3. Tim says:

    After a while of searching and no luck, i finally realized the issue and of course it was something minor and yet obvious.

    I labeled CustomMasterUrl and MasterUrl both with capital “URL” so the workflow was failing.

    Thanks again for this article and for your response last week.

  4. Tim says:

    One other question that i’m guessing you’ve come across.

    This works great now on a site where i’ve enabled the app permissions, however, if i’m creating a site with a workflow and attempting to set the masterpage with this approach, the app permissions are not set for that subsite.

    1. Hey Tim – sorry I was traveling today.. To have it set the masterpage for the Subsite you need to make sure the app permissions are set at the Site collection level.

      Notice it’s sitecollection not sitecollection/web.. big difference! Have fun, SharePoint call web service actions are AWESOME 🙂

  5. Hi there Jared, great article! Got it working with no issue 🙂 However I have a query. I’m currently building sites with REST calls and for some reason, when I enable the server publishing feature, the master page setting does not get set to inherit from the parent. So then I’m using your method above to set the master page to a custom one. My question is around setting the master page to inherit from the parent site with a REST call, is that possible? I haven’t had much luck with finding much info on this topic.

    Thanks 🙂

    1. Hey Peter – I don’t think it’s possible because *officially* you can’t create subsites with publishing turned on. So then you can’t have it inherit the masterpage. I’ve always just done the extra call web service action to set the master page. Glad you found the post helpful!

Leave a Reply to Tim Cancel reply