Forum Discussion

Arun C's avatar
Arun C
Copper Contributor
Jun 30, 2017

Activate Site Feature through REST API

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')"; 
                $.ajax({
                    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));
                    }
                });
            }

Error:

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

No RepliesBe the first to reply

Resources