Share via

SyncFolderHierarchy fails for archivemsgfolderroot

Kasinaat Selvi Sukesh 1 Reputation point
2021-03-19T07:52:13.397+00:00

We have a client application running in our environment which uses the SyncFolderHierarchy method to get the folder contents from mailboxes. For some time now we are facing error with getting folder details of certain archive mailboxes in our environment. The client application running in our environment uses EWS proxy code to contact the EWS endpoint with basic authentication.

EWSRequest:

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Header> <ExchangeImpersonation xmlns="http://schemas.microsoft.com/exchange/services/2006/types"> <ConnectingSID> <PrimarySmtpAddress>*****@*****.onmicrosoft.com</PrimarySmtpAddress> </ConnectingSID> </ExchangeImpersonation> <RequestServerVersion Version="Exchange2016" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" /> </soap:Header> <soap:Body> <SyncFolderHierarchy xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"> <FolderShape> <BaseShape xmlns="http://schemas.microsoft.com/exchange/services/2006/types">AllProperties</BaseShape> </FolderShape> <SyncFolderId> <DistinguishedFolderId Id="archivemsgfolderroot" xmlns="http://schemas.microsoft.com/exchange/services/2006/types"> <Mailbox><EmailAddress>*****@*****.onmicrosoft.com</EmailAddress></Mailbox> </DistinguishedFolderId> </SyncFolderId> </SyncFolderHierarchy> </soap:Body> </soap:Envelope> 

EWSResponse:

 <?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:ErrorNoRespondingCASInDestinationSite</faultcode> <faultstring xml:lang="en-US">Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.</faultstring> <detail> <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorNoRespondingCASInDestinationSite</e:ResponseCode> <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.</e:Message> </detail> </s:Fault> </s:Body> </s:Envelope> These are the SOAP Responses I am getting. Please provide your insights in this issue. Thanks in advance. 
Microsoft 365 and Office | Development | Other
Exchange | Exchange Server | Development
Microsoft 365 and Office | Development | Microsoft 365 Publishing
0 comments No comments

2 answers

Sort by: Most helpful
  1. Glen Scales 4,446 Reputation points
    2021-04-22T01:07:02.303+00:00

    One thing I would try is try using the Guid of the archive mailbox (you'll need to use Get-Mailbox -archive to get it) in the AnchorMailbox header and see if that makes a difference https://developer.microsoft.com/en-us/office/blogs/error-improvement-for-invalid-x-anchormailbox-in-rest-api-calls/

    Was this answer helpful?


  2. Glen Scales 4,446 Reputation points
    2021-03-21T22:52:26.987+00:00

    That problem is generally caused because you not setting the X-AnchorMailbox header to the mailbox you are impersonating, if your using WSDL proxy code you need to do something like the following to override the GetWebRequest method of the ExchangeServerBinding Class eg

        class CustomExchangeServiceBinding: ExchangeServiceBinding
        {
            public String AnchorMailbox { get; set; }
            protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request)
            {
    
                if (!String.IsNullOrEmpty(AnchorMailbox))
                {
                    request.Headers.Add("X-AnchorMailbox", AnchorMailbox);
                }
                System.Net.HttpWebResponse
                response = (System.Net.HttpWebResponse)base.GetWebResponse(request);
                return response;
            }
        }
    

    Then use your custom class instead of ExchangeServiceBinding

    CustomExchangeServiceBinding esb = new CustomExchangeServiceBinding();
    

    You can also modify the referances.cs file directly but if you ever refresh you proxies the changes would be lost

    Was this answer helpful?


Your answer

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