1

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?

  • As Vardhaman pointed out there is an issue with your web template. Are familiar with Fiddler? Try Fiddling the web service request/response and see if there's any clues in there. – Derek Gusoff Jul 31 '13 at 13:29
  • I'm going to try that. Hopefully I can find any clues in there – Marlou Aug 1 '13 at 7:10
  • It's getting even stranger. Sometimes it works and most of the times it don't. I compared the 2 requests in Fiddler, but they are the exact same size and I don't see any errors or other differences in the request. I'm only getting a different response :( – Marlou Aug 1 '13 at 8:25
  • could be a timeout issue. What are you getting in the response when it fails? – Derek Gusoff Aug 1 '13 at 13:18
  • This is the response I'm getting [ { "SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.1810.1206","ErrorInfo":{ "ErrorMessage":"The request uses too many resources.","ErrorValue":null,"TraceCorrelationId":"96b0349c-ba64-80fa-37bb-294a51983fc7","ErrorCode":-2130246262,"ErrorTypeName":"Microsoft.SharePoint.SPException" },"TraceCorrelationId":"96b0349c-ba64-80fa-37bb-294a51983fc7" } ] – Marlou Aug 1 '13 at 13:27
1

It could be something to do with your Custom WebTemplate. What is the size of the template? Does it have lots of lists, pages, assets etc? Also check if you can create a site programmatically with the Server Object Model using your custom template.

See here: http://macslui.blogspot.in/2013/06/how-to-change-maxreceivedmessagesize.html

  • Document templates can also add lots of bloat to a web template. – Derek Gusoff Jul 31 '13 at 13:32
  • The WSP is 792 kb and it has 12 lists in it. Would that be too much? I can't create the site with the server object model because I'm using SharePoint online. However I've tried to create a site based on my template in the interface and that works like it should. – Marlou Aug 1 '13 at 7:03
  • Derek, I have a number of document templates in it. Is it the number of templates that can cause problems or is it the size of the document templates? – Marlou Aug 1 '13 at 7:06
  • Yes I think the WSP is too big and that's why the call is taking too long and its failing. – Vardhaman Deshpande Aug 1 '13 at 7:11
  • I removed the document templates from my wsp and the wsp is now 286 kb but it still fails with the same message :( – Marlou Aug 13 '13 at 11:48
0

The template was created in a site collection that was upgraded from SP2010 to SP2013. I couldn't create a site with this template using the client object model in another site collection that was created in SP2013. I've recreated the template in the SP2013 site collection and that seems to work. Maybe there was something wrong with my site collection after the upgrade to SP2013. Still a strange error with a strange solution. :S

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.