I am creating some SharePoint hosted apps, and have decided to use Napa Office 365 Developer Tools for ease of setup, and then export the projects to Visual Studio at a later date if required.

I have a problem calling cross domain to retrieve information from a list on the SPHostWeb.

My code is from the following example project

(function () {

    'use strict';

    var user = context.get_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 () {

    function getHostUrl () {
        var args = window.location.search.substring(1).split("&");
        var spHostUrl = "";
        for (var i = 0; i < args.length; i++) {
            var n = args[i].split("=");
            if (n[0] == "SPHostUrl")
                spHostUrl = decodeURIComponent(n[1]);
        return spHostUrl;               

    function getAppWebUrl () {
        var appWebUrl = "";
        var args = window.location.search.substring(1).split("&");
        for (var i = 0; i < args.length; i++) {
            var n = args[i].split("=");
            if (n[0] == "SPAppWebUrl")
                appWebUrl = decodeURIComponent(n[1]);
        return appWebUrl;

    // Get Host web title
    function getHostWebTitle() {
        var spHostUrl = getHostUrl();
        var appWebUrl = getAppWebUrl();

        //Load Libraries
        var scriptbase = spHostUrl + "/_layouts/15/";
        var list = "Links";     

        jQuery.getScript(scriptbase + "MicrosoftAjax.js").then(function (data) {
            return jQuery.getScript(scriptbase + "SP.Runtime.js");
        }).then(function (data) {
            return jQuery.getScript(scriptbase + "SP.js");
        }).then(function (data) {
            return jQuery.getScript(scriptbase + "SP.RequestExecutor.js");
        }).then(function (data) {

            var executor = new SP.RequestExecutor(appWebUrl);
                            appWebUrl +
                            "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('" + list + "')/items?$select=Title&@target='" +
                            spHostUrl + "'",
                        method: "GET",
                        headers: { "Accept": "application/json; odata=verbose" },
                        success: function (data) {
                        error: function (data) {



My code follows all the way through to the executor.executeAsync request, however comes back with the following error: value:

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


I think you need to provide read access to your app on your list. Due to this it is throwing access denied error.

See the MSDN link for detail information on App permission http://msdn.microsoft.com/en-us/library/office/fp142383(v=office.15).aspx

| improve this answer | |
  • 1
    Your spot on in regards to permission (clearly) - but it appears that he is probably missing the "site collection" permission. Without that you can't access the host web. In the NAPA tools - open up properties (small wrench icon) and you will see the permission tab where you can set App permission requirements. – Jesus Shelby Jan 12 '15 at 5:02
  • 1
    in the App Manifest file, have you set the permission of the app, if you are retrieving the List data you need to mention permissions as Read, Then while installing the app it will ask you to choose the List. Select the there from which you need to get the data. – Akarsh Gupta Jan 12 '15 at 5:38
  • thanks for your feedback, this seems to be the likely issue, will attempt this tomorrow and let you know how it goes. – svnm Jan 12 '15 at 10:53
  • Worked perfectly once I set the List permission to Write, Thanks – svnm Jan 21 '15 at 21:42

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.