Activate Site Feature through REST API

Copper Contributor

I'm trying to activate site level feature by using REST API in SharePoint Hosted App. I've given full control at Site Collection & Site level with App only Calls. But I'm getting "Access Denied Error" with 403 status. 

function bindButtonClick() {

            var featuresURI = hostUrl + "/_api/web/features/add('a7a2793e-67cd-4dc1-9fd0-43f61581207a')"; 
                    url: featuresURI,
                    method: 'POST',
                    headers: {
                        "Accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    success: function (data) {
                        console.log("Feature Activated");
                    error: function (data) {
                        console.log("error: " + JSON.stringify(data));


Failed to load resource: the server responded with a status of 403 (Forbidden)
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"}


4 Replies

Hi @Arun C


I would look into PnP-Js-Core.


import pnp from "sp-pnp-js";

let web = pnp.sp.web;

// activate the minimum download strategy feature
web.features.add("87294c72-f260-42f3-a41b-981a2ffce37a").then(f => {








Hi @Pieter Veenstra,


Thanks for your comment..

I've tried the same within SHA, But still facing issues.s


$pnp.sp.crossDomainWeb(addinweb, hostweb).get().then(function (success) {
        success.web.features.add("a7a2793e-67cd-4dc1-9fd0-43f61581207a").then(r =>
        }).catch(function (err)
    }).catch(function (err) {


I'm getting error 

TypeError: Cannot read property 'features' of undefined


Does instead of 


$pnp.sp.crossDomainWeb(addinweb, hostweb).get().....

maybe somethign like this work:


$pnp.sp.crossDomainWeb(addinweb, hostweb).features........
I've tried the same, but getting error
"Cannot read property 'add' of undefined"