2014-10-01

This post illustrates how to create a new SharePoint Site based on custom template using Web API.

Required parameters:

  • contextUrl,
  • url,
  • title,
  • Webtemplate

Where:

var requestUri = contextUrl + '/_api/web/webs/add'; 
return $.ajax({
    url: requestUri,
    type: "POST",
    data: "{ 'parameters': { '__metadata': { 'type': 'SP.WebCreationInformation' }, \
    'Title': '" + title + "', 'Url': '" + url + "', 'WebTemplate': '" + webTemplate + "', \
    'UseSamePermissionsAsParentSite': true } }",
     headers: { 
             "X-RequestDigest": $("#__REQUESTDIGEST").val(),
              "accept": "application/json;odata=verbose",
               "content-type": "application/json;odata=verbose",
                "content-length": 92625
           },
      complete: function (data, err) {
                                                     console.log(data);
      }
});

 

About the author 

Gerardo Nacchia