Exchange Web Services EWS "FindFolders" produces a 500 Internal Server Error in the response

Tunrip 85 Reputation points
2023-04-13T13:50:29.94+00:00

Over the last few days, a call to FindFolders in the EWS API returns a 500 Server Error in the server response. The error always occurs in the last item returned by FindFolders. Here's an example response. I have omitted the previous t:Folder responses and truncated folder ids.

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Header>
		<h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="6319" MinorBuildNumber="4" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
	</s:Header>
	<s:Body>
		<m:FindFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
			<m:ResponseMessages>
				<m:FindFolderResponseMessage ResponseClass="Success">
					<m:ResponseCode>NoError</m:ResponseCode>
					<m:RootFolder IndexedPagingOffset="14" TotalItemsInView="14" IncludesLastItemInRange="true">
						<t:Folders>
							<t:Folder>
								<t:FolderId Id="AAEu..." ChangeKey="AQAA..."/>
								<t:ParentFolderId Id="AQEu..." ChangeKey="AQAA..."/>
								<t:FolderClass>IPF.Note</t:FolderClass>
								<t:DisplayName>ZZ Test Emails</t:DisplayName>
								<t:TotalCount>0</t:TotalCount>
								<t:ChildFolderCount>1</t:ChildFolderCount>
								<t:<?xml version="1.0" encoding="utf-8" ?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
									<s:Header>
										<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">*</Action>
									</s:Header>
									<s:Body>
										<s:Fault>
											<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInternalServerError</faultcode>
											<faultstring xml:lang="en-US">An internal server error occurred. The operation failed.</faultstring>
											<detail>
												<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInternalServerError</e:ResponseCode>
												<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">An internal server error occurred. The operation failed.</e:Message>
											</detail>
										</s:Fault>
									</s:Body>
								</s:Envelope>

We use EWS through the EWS Managed API and this causes an error processing the XML response from the server: System.Xml.XmlException: ''<', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 926.' I have tried doing things like reducing the number of items returned by the FolderView, but the error always occurs in the last item in the FindFinderResults. It essentially looks like it's trying to read beyond 'EOF' and subsequently an (I guess) unhandled error occurs. An issue has been opened up on the GitHub for the EWS Managed API, but as the root error seems to be on the EWS side I guess this is the best place to get it noticed. It looks like this issue was already reported here, but thought it might be best to start a new thread as the existing one was more of a question than a problem report. If there's a more appropriate place to raise this issue please let me know. Thank you! :)

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
556 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Peter Ward 20 Reputation points
    2023-04-14T10:11:34.9733333+00:00

    Same problem for us as well, started 11 April 11:16 pm (UK time). The xml response Microsoft posts back does include some of the public folders, but then it breaks at the end of the file and returns an internal server error inside the xml document. This leads to the client app reporting an error "'<', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 6789." (because the xml response is malformed due to the internal server error) We raised a ticket with Microsoft yesterday and I showed an engineer the issue where it occurred in our code, also gave them our log files, including the request and responses, and public folder ids. Hopefully Microsoft will fix this soon as it's clearly a significant issue and is causing disruption across different businesses.

    4 people found this answer helpful.

  2. Cyberghis 0 Reputation points
    2023-04-14T20:14:48.08+00:00

    Update: I had the same problem this morning. Now I have a response from EWS: So still not working...

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope
    	xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    	<s:Body>
    		<s:Fault>
    			<faultcode
    				xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorExceededConnectionCount
    			</faultcode>
    			<faultstring xml:lang="en-US">You have exceeded the available concurrent connections for your account.  Try again once your other requests have completed.</faultstring>
    			<detail>
    				<e:ResponseCode
    					xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorExceededConnectionCount
    				</e:ResponseCode>
    				<e:Message
    					xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">You have exceeded the available concurrent connections for your account.  Try again once your other requests have completed.
    				</e:Message>
    				<t:MessageXml
    					xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    					<t:Value Name="Policy">MaxConcurrency</t:Value>
    					<t:Value Name="MaxConcurrencyLimit">27</t:Value>
    					<t:Value Name="ErrorMessage">This operation exceeds the throttling budget for policy part 'MaxConcurrency', policy value '27',  Budget type: 'Ews'.  Suggested backoff time 0 ms.</t:Value>
    				</t:MessageXml>
    			</detail>
    		</s:Fault>
    	</s:Body>
    </s:Envelope>
    
    0 comments No comments

  3. Cyberghis 0 Reputation points
    2023-04-17T14:02:26.59+00:00

    Update: Back to normal this morning for me.


  4. ReMED Services Orders 0 Reputation points
    2024-01-10T16:04:10.6366667+00:00

    I'm having a sudden bug with FindFolders as of recent. I have no changes to my code however recently this line is throwing an error. (I'm dependent on this line, so any advise is much appreciated!)

    var ewsClient = new ExchangeService();
    ewsClient.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
    ewsClient.Credentials = new OAuthCredentials(authResult.AccessToken);
    ewsClient.ImpersonatedUserId =
    new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mailbox);

    //Include x-anchormailbox header
    ewsClient.HttpHeaders.Add("X-AnchorMailbox", mailbox);

     

    var folders = ewsClient.FindFolders(WellKnownFolderName.Inbox, new FolderView(10));

     

    This last line throws an error:

    Specified value has invalid HTTP Header characters.
    Parameter name: name

    Thank you for helping me with this!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.