1

Need to activate SharePoint Server Publishing feature from SharePoint Hosted App by using REST API at Site level. I've tried below code,

function activateFeature() {
$.ajax({
url: siteURL + "/_api/web/features/add('94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb')",
type: "POST",
headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {

},
error: function (err) {
    alert("Error: " + JSON.stringify(err));
}
});

But I'm getting 403 forbidden error.

error: {"readyState":4,"responseText":"{\"error\":{\"code\":\"-2147024891, System.UnauthorizedAccessException\",\"message\":{\"lang\":\"en-US\",\"value\":\"Access denied. You do not have permission to perform this action or access this resource.\"}}}","status":403,"statusText":"Forbidden"}

Update:

I've tried with adding permissions in appmanifest. But still no luck!!

  • Any updates on this? – Arun Jun 19 '17 at 11:37
  • what permissions you added in the appmanifest ? – Gautam Sheth Jun 20 '17 at 12:37
  • @GautamSheth Given Full Control to Site & Site Collection Level. – Arun Jun 20 '17 at 12:53
  • hmm, does the user running the app have these permissions ? – Gautam Sheth Jun 20 '17 at 12:53
  • @GautamSheth yes.. User is Global Admin of O365 & Site Collection Admin. – Arun Jun 20 '17 at 13:47

Your Answer

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

Browse other questions tagged or ask your own question.