SharePoint System.Net.WebException:“远程服务器返回错误: (414) REQUEST URI TOO LONG。”
2024-12-26 20:35 四毛的家 阅读(4) 评论(0) 编辑 收藏 举报SharePoint CSOM执行下面代码时报错:
string fileServerRelativeUrl = "/xxxx/2003249_98.RXE";
using (var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctxOriginal, fileServerRelativeUrl)) using (var reader = new StreamReader(fileInfo.Stream)) { Microsoft.SharePoint.Client.File.SaveBinaryDirect( //Client Context ctxTarget, // Server relative url of the document //listTarget.RootFolder.ServerRelativeUrl + file.ServerRelativeUrl.Replace(libraryServerRelativeUrlOriginal,""),//新路径 fileServerRelativeUrlTarget, // Content of the file reader.BaseStream, // Overwrite file if it's already exist true); ctxTarget.ExecuteQuery(); }
报:
尝试修改web.config如下
在Web.config文件中添加以下配置。
-
<system.web>
-
<httpRuntime maxRequestLength="102400" maxQueryStringLength="102400"/>
-
</system.web>
-
<system.webServer>
-
<security>
-
<requestFiltering>
-
<requestLimits maxAllowedContentLength="102400" maxQueryString="102400" />
-
</requestFiltering>
-
</security>
-
</system.webServer>
未能解决。
经过各种尝试,一篇来自stackoverflow的帖子提醒了我,
“It was a permission problem. The IIS user did not have read-rights to the folder. Changed to use application pool identity instead and now its working.”
我的账号权限足够。经过查询原来是SharePoint管理中心设置“被禁止的文件类型”导致的。读取的文件是Rxe类型,被禁止了。
参考:
https://blog.csdn.net/qq_38974638/article/details/108500973
https://stackoverflow.com/questions/46190612/the-page-was-not-displayed-because-the-request-uri-is-too-long
----------------------------------------------------
- 文字少的博文不允许投稿到该网站分类 (以下内容跟本文主题无关)
---------------------------------------------------------
https://learn.microsoft.com/en-us/answers/questions/636509/csom-how-to-copy-a-document-from-one-document-libr
CSOM: How to copy a document from one document library to another documents library?
I have a requirement to copy documents that meets a certain criteria ( i.e once a document's approval status = approved) to an Archived documents library. I am looping through all the sites and using CAML query to filter out the documents with approved status but I have no idea how to copy the document to a different library location using CSOM C# after checking this condition. Also, I need the document to be replaced in case it is already present in the archived library.
Note: The archived library is in a different site collection.
Any help is greatly appreciated. Thank you in advance.
var bookname = item.DisplayName; string bookLocation = $"{rootFolder.ServerRelativeUrl}/{bookname}"; var absoluteUrl = new Uri(ctx.Url).GetLeftPart(UriPartial.Authority) + bookLocation; var srcUrl = absoluteUrl; var destUrl = "https://abc.sharepoint.com/sites/Archive"; var srcLibrary = "Documents"; var destLibrary = "Records"; ClientContext destContext = new ClientContext(destUrl); ClientContext srcContext = new ClientContext(srcUrl); destContext.Credentials = SPAuth.GetSPOnlineCredentials(); srcContext.Credentials = SPAuth.GetSPOnlineCredentials(); Web srcWeb = srcContext.Web; List srcList = srcWeb.Lists.GetByTitle(srcLibrary); Web destWeb = destContext.Web; destContext.Load(destWeb); destContext.ExecuteQuery(); try { Microsoft.SharePoint.Client.File file1 = srcContext.Web.GetFileByServerRelativeUrl(bookLocation); srcContext.Load(file1); srcContext.ExecuteQuery(); string location = destWeb.ServerRelativeUrl.TrimEnd('/') + "/" + destLibrary.Replace(" ", "") + "/" + file1.Name; FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(srcContext, file1.ServerRelativeUrl); Microsoft.SharePoint.Client.File.SaveBinaryDirect(destContext, location, fileInfo.Stream, true); } catch (Exception ex) { telemetry.TrackException(new Exception("Failed to copy the book to archive library", ex)); }
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 本地部署 DeepSeek:小白也能轻松搞定!
· 传国玉玺易主,ai.com竟然跳转到国产AI
· 自己如何在本地电脑从零搭建DeepSeek!手把手教学,快来看看! (建议收藏)
· 我们是如何解决abp身上的几个痛点
· 如何基于DeepSeek开展AI项目
2016-12-26 SharePoint 2013 设置网站集为”只读”
2016-12-26 SharePoint 2010/2013/2016内容数据库与网站集的关系
2016-12-26 SharePoint 2010 数据库xxx的事务日志已满
2016-12-26 沙盒解决方案解决SharePoint 2013 以其他身份登陆的问题
2016-12-26 SharePoint 2013 沙盒解决方案不能激活(激活按钮不可用)