简体   繁体   English

尝试从Sharepoint存储库读取文件时出现401错误

[英]Getting 401 error when trying to read file from sharepoint repository

I have been using this code to read in a file from a document repository in sharepoint: 我一直在使用以下代码从sharepoint中的文档存储库中读取文件:

WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create("http://servername/realestate/SiteAssets/navigation.txt");
objRequest.Timeout = 10000;
objRequest.UseDefaultCredentials = true;
objRequest.Proxy.Credentials = objRequest.Credentials;

objResponse = (WebResponse)objRequest.GetResponse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
    navBar = sr.ReadToEnd();
    sr.Close();
}

I just migrated to a new environment, and I am getting a 401 unauthorized error with this code - but, instead of using servername, I am now using hostname (since the new environment has a domain assigned to it). 我刚刚迁移到新环境,此代码出现401未经授权的错误-但是,我现在不使用服务器名,而是使用主机名(因为新环境已分配了域)。 How can I navigate this issue, even though I am now using a host in my HttpWebRequest object? 即使我现在在HttpWebRequest对象中使用主机,也该如何解决此问题? And, if this should not be causing the issue, I would like to hear recommendations as well. 而且,如果这不应该引起问题,我也想听听建议。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 下载文件时出现401错误-SharePoint ClientContext - 401 error when downloading file - SharePoint ClientContext 使用 SaveBinaryDirect (C#) 将文件上传到 SharePoint Online 时出现 401 错误 - 401 Error When Uploading File to SharePoint Online with SaveBinaryDirect (C#) 使用来自 Sharepoint 和 C# 的链接时出错((401)未经授权) - Error when use link from Sharepoint with C# ( (401) unauthorized ) 尝试从SharePoint服务器(FileInfo / FileStream)打开文件的C#错误 - Getting error in C# trying to open file from SharePoint server (FileInfo/FileStream) 远程服务器返回错误:(401)未经授权(尝试访问存储库svn时) - The remote server returned an error: (401) Unauthorized (when trying to access repository svn) 尝试上传文件时出现401/403错误 - Getting 401 / 403 errors trying to upload a file 为什么在尝试验证令牌时得到401 - Why getting 401 when trying validating Token 我收到一条错误消息,显示“不支持给定路径的格式”。 尝试将音频文件上传到 sharepoint - I am getting an error that reads “The given path's format is not supported.” when trying to upload audio file to sharepoint 尝试进行客户端SharePoint编码时出现虚假(?)文件未找到错误 - Bogus (?) File Not Found error when trying to do client SharePoint coding 尝试获取请求令牌时出现 401 错误 - 401 Error when trying to get Request Token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM