I have several user accounts in Office 365 tenant. Two of them are almost identical (have similar settings but different contact info and name). I try to fetch information (such as all folders and items) in user's mailbox using GetFolder operation from EWS API that contains next body:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"/>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>[email protected]</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<FolderShape>
<t:BaseShape>AllProperties</t:BaseShape>
<t:AdditionalProperties> </t:AdditionalProperties>
</FolderShape>
<FolderIds>
<t:DistinguishedFolderId Id="outbox"/>
</FolderIds>
</GetFolder>
</soap:Body>
</soap:Envelope>
I can successfully get info for one of these two mailboxes but when an error reply with the next body:
<?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:ErrorNonPrimarySmtpAddress</faultcode>
<faultstring xml:lang="en-US">The primary SMTP address must be specified when referencing a mailbox.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorNonPrimarySmtpAddress</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The primary SMTP address must be specified when referencing a mailbox.</e:Message>
<t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:Value Name="Primary"/>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Why do I get such ErrorNonPrimarySmtpAddress error response? What can be the problem when I fetch data in the mailbox of the second user?