vendredi 23 janvier 2015

Cross SiteCollection call with JSOM not working



I got a problem and my brain says "yes you made no mistake" but it doesn't work. Here is my problem:


Ich have a SharePoint hosted App which has "Tenant read" permissions in the App Manifest.


App permissions are tenant read


That App has an AppPart which is installed on SiteCollection A (on the root like http://ift.tt/1CXGgPi). I also have a SiteCollection B (like http://ift.tt/1CqZJtN) and in that SiteCollection is a List. Now the App from SiteCollection A wants to acces SiteCollection B with the Cross Site Scripting Approach with JSOM. And I always get the typical "permission denied" message



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



My Code for getting the context is written in TypeScript! Here is the part of the Code were I create the context and the web!



var appWebUrl: string = FuM.Helper.ParameterHelper.getWebAppUrl();
var targetWebUrl: string = "http://ift.tt/1CqZJtN";

context = new SP.ClientContext(appWebUrl);
var factory = new SP.ProxyWebRequestExecutorFactory(appWebUrl);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, targetWebUrl);

getListItemsAsync("Announcements", "", "", context, appContextSite.get_web())


and the code the gettings the list items



static getListItemsAsync(
listTitle: string,
camlQuery: string,
include: string,
clientContext: SP.ClientContext,
targetWeb: SP.Web): JQueryPromise<SP.ListItemCollection> {

var deferred = $.Deferred<SP.ListItemCollection>();

var propertyList = targetWeb.get_lists().getByTitle(listTitle);

var query = new SP.CamlQuery();

if (camlQuery !== undefined && camlQuery !== '') {
query.set_viewXml(camlQuery);
}

var listItems = propertyList.getItems(query);

if (include !== undefined && include !== '') {
clientContext.load(listItems, include);
} else {
clientContext.load(listItems);
}

clientContext.executeQueryAsync(
() => { deferred.resolve(listItems); },
(sender, args) => { FuM.Helper.LogHelper.logError(args); }
);

return deferred.promise();
}


Does anyone see any mistake? Am I using the wrong urls to initialize or the wrong technique?








0 commentaires:

Enregistrer un commentaire