I'm trying to create a site in my sharepoint hosted app using the javascript client object model in a SharePoint online site. I use a custom template when creating the site. This is my code:
var webCreationInfo = new SP.WebCreationInformation();
webCreationInfo.set_title(customerName);
webCreationInfo.set_url(customerCode);
webCreationInfo.set_webTemplate(templateId);
customerWeb = web.get_webs().add(webCreationInfo);
context.load(customerWeb);
context.executeQueryAsync(
Function.createDelegate(this, CreateSiteSucceeded),
Function.createDelegate(this, ClientContextFailed));
The clientcontext is earlier instantiated in a separate function. The customercode, customername and template id are just variables with a value. When I execute the function, I get the following exception: "The request uses too many resources".
If I change the template to the standard team site like this:
webCreationInfo.set_webTemplate("STS#0");
Then I don't get exceptions.
I've read that this error could have something to do with exceeding the 2 mb request limit or exceeding the max number of objects paths which is 256 by default. This looks like a really basic operation to me. Why am I getting this error? Or how can I prevent it?