从应用程序访问时拒绝来自位于不同Web应用程序中的Web列出项目 [英] Access denied, from an app, when geting List items from a web located in different web applcation

查看:65
本文介绍了从应用程序访问时拒绝来自位于不同Web应用程序中的Web列出项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个SharePoint托管应用程序并安装在位于WebApplication1上的站点上。此应用程序尝试从位于Webapplication2上的站点中的列表中获取列表项。我尝试过不同的解决方案(REST和csom),但它会生成
访问被拒绝。以下是我的代码。



我在清单文件中添加了一个RemoteEndPoint,它指向包含列表的网页。

I have create a SharePoint Hosted App and installed on a Site which is located on WebApplication1. This app tries to get list items from a list in a site which is located on Webapplication2. I have tried different solutions (REST and csom) but it generates access denied. Following is my code.

I have added a RemoteEndPoint to the manifest file which points to the web that contains the list.

var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));

var blogWebUrl = "https://webapplication2.com/personal/userName/Blog";

var context1 = new SP.ClientContext(appweburl);

var factory = new SP.ProxyWebRequestExecutorFactory(appweburl);

context1.set_webRequestExecutorFactory(factory);

var blogWebContext = new SP.AppContextSite(context1, blogWebUrl);

var blogWeb = blogWebContext.get_web();

var list = blogWeb.get_lists().getByTitle("Posts");

var camlString =
  "<View><ViewFields>" +
      "<FieldRef Name='Title' />" +
      "<FieldRef Name='Body' />" +
  "</ViewFields></View>";

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(camlString);
var allPosts = list.getItems(camlQuery);

context1.load(allPosts, "Include(Title, Body)");

context1.executeQueryAsync(
   Function.createDelegate(this, function (sender, args) {
       alert("okkkkk");
   }),
    Function.createDelegate(this, function (sender, args) {
        alert('failed: ' + args.get_message());
    })
);

推荐答案

跨域JS库可以从同一租户内的域中获取数据。对于现场SharePoint安装,同一Web应用程序中的方法。
The cross-domain JS library can get data from domains within the same tenancy. In the case of an onsite SharePoint installation, the means within the same web application.


这篇关于从应用程序访问时拒绝来自位于不同Web应用程序中的Web列出项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆