SharePoint System.Net.WebException:“远程服务器返回错误: (414) REQUES ...

打印 上一主题 下一主题

主题 906|帖子 906|积分 2718

SharePoint CSOM执行下面代码时报错:
string fileServerRelativeUrl = "/xxxx/2003249_98.RXE";
  1. using (var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctxOriginal, fileServerRelativeUrl))
  2. using (var reader = new StreamReader(fileInfo.Stream))
  3. {
  4.     Microsoft.SharePoint.Client.File.SaveBinaryDirect(
  5.     //Client Context
  6.     ctxTarget,
  7.     // Server relative url of the document
  8.     //listTarget.RootFolder.ServerRelativeUrl + file.ServerRelativeUrl.Replace(libraryServerRelativeUrlOriginal,""),//新路径
  9.     fileServerRelativeUrlTarget,
  10.     // Content of the file
  11.     reader.BaseStream,
  12.     // Overwrite file if it's already exist
  13.     true);
  14.     ctxTarget.ExecuteQuery();
  15. }
复制代码
 
报:

尝试修改web.config如下
在Web.config文件中添加以下设置。












未能办理。
颠末各种尝试,一篇来自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.
  1. var bookname = item.DisplayName;  
  2. string bookLocation = $"{rootFolder.ServerRelativeUrl}/{bookname}";                                 
  3. var absoluteUrl = new Uri(ctx.Url).GetLeftPart(UriPartial.Authority) + bookLocation;  
  4. var srcUrl = absoluteUrl;  
  5. var destUrl = "https://abc.sharepoint.com/sites/Archive";  
  6. var srcLibrary = "Documents";  
  7. var destLibrary = "Records";  
  8. ClientContext destContext = new ClientContext(destUrl);  
  9. ClientContext srcContext = new ClientContext(srcUrl);  
  10. destContext.Credentials = SPAuth.GetSPOnlineCredentials();  
  11. srcContext.Credentials = SPAuth.GetSPOnlineCredentials();                                 
  12. Web srcWeb = srcContext.Web;  
  13. List srcList = srcWeb.Lists.GetByTitle(srcLibrary);                                 
  14. Web destWeb = destContext.Web;  
  15. destContext.Load(destWeb);  
  16. destContext.ExecuteQuery();  
  17. try  
  18. {  
  19.     Microsoft.SharePoint.Client.File file1 = srcContext.Web.GetFileByServerRelativeUrl(bookLocation);  
  20.     srcContext.Load(file1);  
  21.     srcContext.ExecuteQuery();  
  22.     string location = destWeb.ServerRelativeUrl.TrimEnd('/') + "/" + destLibrary.Replace(" ", "") + "/" + file1.Name;  
  23.     FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(srcContext, file1.ServerRelativeUrl);  
  24.     Microsoft.SharePoint.Client.File.SaveBinaryDirect(destContext, location, fileInfo.Stream, true);  
  25. }  
  26. catch (Exception ex)  
  27. {  
  28.     telemetry.TrackException(new Exception("Failed to copy the book to archive library", ex));  
  29. }                                
复制代码
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心
文-字-少-的-博-文-不-允-许-投-稿-到-该-网-站-分-类,真*恶*心

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

去皮卡多

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表