Reputation: 41
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("[email protected]", "********");
Mailbox mb = new Mailbox("[email protected]");
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. The remote server returned an error: (413) Request Entity Too Large. ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.
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. Please advice how to solve it, thanks.
Upvotes: 0
Views: 3395
Reputation: 165
In my case, Exchange 2013 CU12, I tweaked the SSL settings of IIS and got a positive response from the 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".
Upvotes: 1
Reputation: 22032
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://learn.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.
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. 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). So i would look at what else may have been recently installed on that server.
Upvotes: 1