使用SharePoint 2010托管客户端应用程序读取SharePoint Online页面的二进制流时出现403 Forbidden错误 [英] Getting 403 Forbidden error while reading binary stream of SharePoint Online page using SharePoint 2010 Managed Client application

查看:169
本文介绍了使用SharePoint 2010托管客户端应用程序读取SharePoint Online页面的二进制流时出现403 Forbidden错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要从SharePoint 2010客户端对象模型中读取SharePoint O365网站页面的二进制流,但是遇到异常"远程服务器返回错误(403):禁止"在执行 OpenBinaryDirect()时 方法

我们尝试过的方法:

  1.       通过Microsoft.SharePoint.Client.dll的"OpenBinaryDirect" 方法. (这在SharePoint 2013环境中有效,但在SharePoint 2010中给出403错误)

      FileInformation fileInformation = File.OpenBinaryDirect(clientContext,(string)f.ServerRelativeUrl);
       使用(System.IO.StreamReader sr = new System.IO.StreamReader(fileInformation.Stream))
        {
            //将流读取为字符串,然后将字符串写入控制台.
           字符串行= sr.ReadToEnd();
            Console.WriteLine(line);
        }

我们也尝试通过cookie身份验证创建SharePoint在线网站上下文.

请建议如何使用SharePoint 2010客户端dll读取SharePoint Online文件内容.

解决方案

如果要访问SharePoint Online内容,请使用SharePoint Online客户端dll.

使用NuGet安装Microsoft.SharePointOnline.CSOM.

https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM

最好的问候,

丹尼斯


We need to read binary stream of SharePoint O365 site page from SharePoint 2010 client object model, but getting an exception "Remote server returned an error (403): forbidden"   while executing OpenBinaryDirect() method

Methods we tried:

  1.        By Microsoft.SharePoint.Client.dll's "OpenBinaryDirect" method. (this is working in SharePoint 2013 environment but giving 403 error in SharePoint 2010)

      FileInformation fileInformation = File.OpenBinaryDirect(clientContext, (string)f.ServerRelativeUrl);
        using (System.IO.StreamReader sr = new System.IO.StreamReader(fileInformation.Stream))
        {
            // Read the stream to a string, and write the string to the console.
            String line = sr.ReadToEnd();
            Console.WriteLine(line);
        }

We have tried creating SharePoint online site context through cookie authentication also.

Please suggest how to read the SharePoint Online file content using SharePoint 2010 client dll.

解决方案

Hi,

If you want to access SharePoint Online content, please use SharePoint online client dlls.

Install Microsoft.SharePointOnline.CSOM using NuGet.

https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM

Best Regards,

Dennis


这篇关于使用SharePoint 2010托管客户端应用程序读取SharePoint Online页面的二进制流时出现403 Forbidden错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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