SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get title of a list which is located on Host Site from an SharePoint hosted app by using csom (javascript). I have added permission on Manifest file and chose the list but still getting Access denied on executeQueryAsync. here is my code:

  hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
  var hostcontext = new SP.ClientContext(hostweburl);
  var oList = hostcontext.get_web().get_lists().getByTitle('SliderList');
  var camlQuery = new SP.CamlQuery();
  camlQuery.set_viewXml(' som query to get proper items')
  this.collListItem = oList.getItems(camlQuery);


   hostcontext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

it does not go to either onQuerySuccess or onQueryFailed, it says Access denied on SP_ClientRuntimeContext$executeQueryAsync, sp.runtime.debug.js, line 3103

share|improve this question
up vote 5 down vote accepted

You actually need to generate a SP.ClientContext for the app web and a SP.AppContextSite for the host web. To get a reference to a list in the host web, try the following:

// Get the ClientContext for the app web
clientContext = new SP.ClientContext.get_current();
// Use the host web URL to get a parent context - this allows us to get data from the parent
hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
parentCtx = new SP.AppContextSite(clientContext, hostweburl);
parentWeb = parentCtx.get_web();
parentList = parentWeb.get_lists().getByTitle("SliderList");
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.