【问题标题】:I need to consume data from a SharePoint 2010 through the REST site我需要通过 REST 站点使用来自 SharePoint 2010 的数据
【发布时间】:2017-03-12 10:13:08
【问题描述】:

我需要通过 REST 站点使用来自 SharePoint 2010 的数据。 我通过 ajax + Jquery 请求调用。 我的主机是 localhost,我正在尝试调用其他域的主机。

我正在尝试通过本地计算机上的打字稿项目调用共享点列表

我在我的 HEADER 中设置了跨域:

  $.ajax({
        type: "GET",
        contentType: "application/json;charset=ISO-8859-1",
        url: path,
        dataType: "json",
        cache: false,
        headers: { 'Access-Control-Allow-Origin': '*' },
        crossDomain: true,
        async: false,

        success: function (response) { 
            if (response.d.__next) {
                recursive(response.d.__next);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
            console.log(errorThrown);
            console.log(textStatus);
            console.log(XMLHttpRequest);
        }
    });

我在Source server WebConfig中设置了Cross-origin:

 <httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="http://localhost:50515" />
    <add name="X-MS-InvokeApp" value="1; RequireReadOnly" />
    <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, X-Requested-With, X-File-Name"/>
    <add name="Access-Control-Allow-Methods" value="GET, POST"/>
  </customHeaders>
</httpProtocol>

但是这里发生了这个错误:

XMLHttpRequest cannot load http:MyLocalHost/SiteOrigin/_vti_bin/listdata.svc/person?_=1457982013329. Response for preflight has invalid HTTP status code 401send @ jquery.min.js:4

controller.js:50 DOMException:无法在“XMLHttpRequest”上执行“发送”:无法加载“http:MyLocalHost/SiteOrigin/_vti_bin/listdata.svc/person?_=1457982013329.”。(…) controller.js:51 错误

已经,感谢所有可以帮助我的人

【问题讨论】:

    标签: ajax rest sharepoint-2010 xmlhttprequest typescript1.5


    【解决方案1】:

    这篇文章已经有一年了,所以可能原来的海报已经放弃了。无论如何,您可以将 Nginx 与反向代理一起使用,例如:

    location /sharepoint/ { proxy_pass   http://sharepoint/;}
    

    这次您可以将您的请求致电“http://localhost/sharepoint/”。最后一件事,在 SharePoint 管理中心(Central Admin、Security 然后指定身份验证提供程序)中更改 IIS7 基本身份验证启用非常重要。我希望这对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多