1

Hi I'm new to sharepoint. So I'm trying to develeop sharepoint online app. But there is an error here and I can't find how solve this issue. Error is :

Access denied. You do not have permission to perform this action or access this resource.

App deployed to sharepoint online site. I wrote a script into App.js

function initializePage()
{

    var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    var currentcontext = new SP.ClientContext.get_current();
    var context = new SP.AppContextSite(currentcontext, hostUrl);
    var web = context.get_web(); 

    var slider_list = web.get_lists().getByTitle("Slider");

    //var context = SP.ClientContext.get_current();
    //var user = context.get_web().get_currentUser();

    var user = web.get_currentUser();


    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
    $(document).ready(function () {
        getUserName();
    });

    // This function prepares, loads, and then executes a SharePoint query to get the current users information
    function getUserName() {

        currentcontext.load(user);
        currentcontext.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);

        currentcontext.load(slider_list);
        currentcontext.executeQueryAsync(onSuccess, onFail);
    }

    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
        $('#message').text('Hello ' + user.get_title());
    }

    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    }

    function onSuccess() {

        console.log(slider_list);

    }

    // This function is executed if the above call fails
    function onFail(sender, args) {
        console.log(args.get_message());
    }
}

    function getQueryStringParameter(urlParameterKey) {
        var params = document.URL.split('?')[1].split('&');
        var strParams = '';
        for (var i = 0; i < params.length; i = i + 1) {
            var singleParam = params[i].split('=');
            if (singleParam[0] == urlParameterKey)
                return decodeURIComponent(singleParam[1]);
        }
    }

But I get this error everytime which is wrote above. I hope anyone help me.

  • Do you have full control over the site? – Keerthi Sep 29 '16 at 15:11
2

Double Click your AppManifest.xml and hit the Permissions tab. Add the Site collection and request Full Control for your app

enter image description here

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.