【问题标题】:SharePoint Error The remote server returned an error: (403) ForbiddenSharePoint 错误远程服务器返回错误:(403) Forbidden
【发布时间】:2013-06-13 16:12:03
【问题描述】:

我正在使用 Office 365 开发 Sharepoint 应用程序。它是一个自动托管应用程序,我想从文档库中获取文件 (excel) 流,以便我可以使用 openXML 执行进一步的操作。我收到异常“远程服务器返回错误:(403) Forbidden。”

代码如下:

Microsoft.SharePoint.Client.File file = GetTheFileFromTheDocLibrary("excelfile.xlsx");

            ClientContext clientContext = new ClientContext(Session["SPHostUrl"].ToString());
            FileInformation fInfo = SP.File.OpenBinaryDirect(clientContext, file.ServerRelativeUrl);
            // The remote server returned an error: (403) Forbidden.
            using (MemoryStream memoryStream = new MemoryStream())
            { // other code

注意:相同的代码在提供者托管的应用程序中工作。

【问题讨论】:

    标签: sharepoint-2013 office365


    【解决方案1】:

    根据我们上个月发布的公告http://blogs.office.com/2014/05/16/update-on-autohosted-apps-preview-program/

    ,我建议尽快退出自动托管

    提供商托管应用程序是适合您的方案的方法,您说没有错误,这是个好消息。

    【讨论】:

      【解决方案2】:

      我在 Provider Hosted App 上遇到了类似的问题,它是 .config 文件中的一个丢失、错误或空的 ClientId。

      例子:

      <appSettings>
      <add key="ClientId" value="xxxxx-xxx-xxx-xxx-xxxx" />
      ...
      </appSettings>
      

      【讨论】:

        猜你喜欢
        • 2021-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-13
        相关资源
        最近更新 更多