I'm using SharePoint 2013 and I wrote an AppPart that needs items of a list other than it's host site collection. But it keeps popping up an error indicating that my request has been failed. Access denied!!
Here is my Code in App.js for query the list in another sitecollection:
context = new SP.ClientContext(appweburl); factory = new SP.ProxyWebRequestExecutorFactory(appweburl); context.set_webRequestExecutorFactory(factory); appContextSite = new SP.AppContextSite(context, "http://pouyanserver/sites/Authoring"); this.web = appContextSite.get_web(); mylist = this.web.get_lists().getByTitle('Employees'); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml('<View><RowLimit>10</RowLimit></View>'); var collListItem = mylist.getItems(camlQuery); context.load(mylist); context.load(collListItem); context.executeQueryAsync( Function.createDelegate(this, successHandler), Function.createDelegate(this, errorHandler) );
I have tried these solutions but neither of these worked:
In the AppManifest.xml , In permissions tab I've added SiteCollection and tenant as scopes who has full control.
Solution 2: In the AppManifest.xml code, I've added an appPrincipal as follows:
<AppPrincipal> <Internal AllowedRemoteHostUrl="http://pouyanserver/sites/authoring"/> </AppPrincipal>
What do you think ?