简体   繁体   English

Exchange Web 服务 - 请求失败。 远程服务器返回错误:(413) 请求实体太大

[英]Exchange Web Services - The request failed. The remote server returned an error: (413) Request Entity Too Large

I have this simple code snippet, where I try to fetch folders from specific mailbox我有这个简单的代码片段,我尝试从特定邮箱中获取文件夹

ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

ExchangeService service = new ExchangeService();

service.Credentials = new WebCredentials("ADMIN_USER@corp.contoso.com", "********");

Mailbox mb = new Mailbox("chris@corp.contoso.com");
FolderId fid = new FolderId(WellKnownFolderName.MsgFolderRoot, mb); 

// Set the URL.
service.Url = new Uri("https://<exchange>/EWS/Exchange.asmx");

var findResults = service.FindFolders(
    fid,
    new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep }
);

foreach(var result in findResults)
{
    //result.Load();
    Console.WriteLine(result.DisplayName);
}

It worked fine before, but today's morning it started to return this error以前运行正常,但今天早上它开始返回此错误

Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. Microsoft.Exchange.WebServices.Data.ServiceRequestException:请求失败。 The remote server returned an error: (413) Request Entity Too Large.远程服务器返回错误:(413) 请求实体太大。 ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large. ---> System.Net.WebException:远程服务器返回错误:(413) 请求实体太大。

I tried different ways to solve it - mostly by increasing request entity size limit, but it does not help.我尝试了不同的方法来解决它 - 主要是通过增加请求实体大小限制,但这无济于事。 I suppose code is fine, but VM or Exchange configuration need to be adjusted.我想代码没问题,但需要调整 VM 或 Exchange 配置。 Please advice how to solve it, thanks.请教如何解决,谢谢。

You shouldn't be doing this你不应该这样做

new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep }

It won't work anyway because the maximum number of items that EWS will return will be 1000 anyway so you should implemented proper paging in your code https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-perform-paged-searches-by-using-ews-in-exchange else your code will fail when the Mail folder count exceeds 1000.它无论如何都不起作用,因为 EWS 将返回的最大项目数无论如何都是 1000,因此您应该在代码中实现正确的分页https://docs.microsoft.com/en-us/exchange/client-developer/exchange -web-services/how-to-perform-paged-searches-by-using-ews-in-exchange否则当邮件文件夹计数超过 1000 时,您的代码将失败。

Before you adjust any server settings i would suggest you test EWS using something like the EWS Editor https://github.com/dseph/EwsEditor/releases if that works but your code doesn't then you know the problem lies at the source rather then the destination.在您调整任何服务器设置之前,我建议您使用 EWS 编辑器https://github.com/dseph/EwsEditor/releases 之类的工具测试 EWS,如果可行但您的代码不起作用,那么您就知道问题出在源头上然后是目的地。 There are very few instance where you should ever change IIS setting on a Exchange server for that type of request it shouldn't be necessary (maybe large attachments are the only one I can think off).很少有您应该为那种类型的请求更改 Exchange 服务器上的 IIS 设置的情况,它不应该是必要的(也许大附件是我唯一能想到的)。 So i would look at what else may have been recently installed on that server.所以我会看看最近在该服务器上安装了什么。

In my case, Exchange 2013 CU12, I tweaked the SSL settings of IIS and got a positive response from the Microsoft Remote Connectivity Analyzer .在我的情况下,Exchange 2013 CU12,我调整了 IIS 的 SSL 设置,并从Microsoft Remote Connectivity Analyzer得到了积极响应。

Under the EWS subfolder of the Default Web Site, I changed the "SSL Settings" item "Client certificates" from "Accept" to "Ignore".在默认网站的 EWS 子文件夹下,我将“SSL 设置”项“客户端证书”从“接受”更改为“忽略”。

在此处输入图片说明

暂无
暂无

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

相关问题 远程服务器返回错误:(413)请求实体太大 - The remote server returned an error: (413) Request Entity Too Large 远程服务器返回了意外的响应:(413)请求实体太大 - The remote server returned an unexpected response: (413) Request Entity Too Large WCF错误:远程服务器返回错误:(413)请求实体太大 - WCF error: The remote server returned an error: (413) Request Entity Too Large 错误:远程服务器返回了意外的响应:(413)请求实体太大 - Error: the remote server returned an unexpected response: (413) Request Entity Too Large 文件上传,远程服务器返回错误:(413) Request Entity Too Large - File Upload, The remote server returned an error: (413) Request Entity Too Large Azure云服务“远程服务器返回错误:(413)请求实体太大。” - Azure Cloud Service “The remote server returned an error: (413) Request Entity Too Large.” 远程服务器返回错误:(413)请求实体太大(尝试“每笔在地球上的解决方案”) - The remote server returned an error: (413) Request Entity Too Large (TRIED EVERY SOLUTION ON EARTH) WCF服务“远程服务器返回错误:(413)请求实体太大。” - WCF Service “The remote server returned an error: (413) Request Entity Too Large.” WCF 4.5:发生意外错误:远程服务器返回了意外响应:(413)请求实体太大 - WCF 4.5: An unexpected error occurred: The remote server returned an unexpected response: (413) Request Entity Too Large WCF 服务与 30mb 输入字符串 - 远程服务器返回错误:(413)请求实体太大 - WCF service with 30mb input string - The remote server returned an error: (413) Request Entity Too Large
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM