1

I'm trying to create a SharePoint hosted app that creates a subsite under the hostweb with JSOM. The app has full control on the site collection. Why do i I getting this error message:

enter image description here enter image description here

My code:

function createWebsite() {

var clientContext = new SP.ClientContext('http://sp2013/sites/dev');
this.oWebsite = clientContext.get_web();

var webCreationInfo = new SP.WebCreationInformation();
webCreationInfo.set_title('My New Web Site');
webCreationInfo.set_description('Description of new Web site...');
webCreationInfo.set_language(1033);
webCreationInfo.set_url('MyNewWebSite');
webCreationInfo.set_useSamePermissionsAsParentSite(true);
webCreationInfo.set_webTemplate('STS#0');

oWebsite.get_webs().add(webCreationInfo);
oWebsite.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}
1

Yes, but no, the app does not have full control. The app has permissions to execute code in full control only if the user executing the code has full control of the Site collection.

So you must make sure that the users has permissions to create a subsite as well. You can not elevate permissions in a SharePoint hosted app, for that you must CSOM in C#

  • Thank you for the answar. I thought that apps was running under the app permission, so that you don't need to worry about the users permissions. I'm still getting the same error when running the app with a site collection admin user... – hognis May 27 '14 at 8:08
  • @Robert Lindgren, Can't we use "Allow App only Calls"? – Arun Jul 19 '17 at 13:31
3

SharePoint hosted apps do not have access to oAuth, and get their permissions from the user.

If you wish to give permissions to the app you must use a provider hosted or auto hosted app.

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.