pullsubscription no longer working with oAuth - exchange-server

Looks like there is hardly any activity on EWS here but maybe...
I am in the process of supporting Oauth in my EWS app but i'm stuck on getting events from a pullsubscription.
There's no issue for mailbox folders, only public folders.
The only change in the code is that the exchange service now has Oauthcredentials and impersonates an email address that has owner permissions on the public folder .
When using basic authentication the exchange service credentials are that of a "service account" email address and it does not use impersonation to get a pullsubscribtion on the public folder.
I'm not getting errors when setting the pullsubscription, and I can check that it has an ID, so it is there. However when I issue the getevents method (after adding some items to the folder) nothing fires.
this is the trace of the getevents (i made sure there were events in the folder)
26-8-2022 17:56:31 : EwsRequestHttpHeaders --- <Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2022-08-26 15:56:31Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent:
ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
X-AnchorMailbox: publicfolderstore_bac380fe#domainname.onmicrosoft.com
X-PublicFolderMailbox: publicfolderstore_bac380fe#domainname.onmicrosoft.com
X-PreferServerAffinity: True
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkRPRTZVMFJHdnM0X3FHanBhbU9KTjM1VHVsdmNRWUtjNHlFVDk2YnhfQjgiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbSIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2VkMDc0NDQxLWI4MjUtNDJjYy04ODU2LTE3YWUzYjBiMmY0Mi8iLCJpYXQiOjE2NjE1Mjg5NjcsIm5iZiI6MTY2MTUyODk2NywiZXhwIjoxNjYxNTMyODY3LCJhaW8iOiJFMlpnWUxpVHNzZktUS2x6bGtGdzNoS3Z5WmIyQUE9PSIsImF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hJ44Oh90Ha9xw
</Trace>
26-8-2022 17:56:31 : EwsRequest --- <Trace Tag="EwsRequest" Tid="1" Time="2022-08-26 15:56:31Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:SmtpAddress>account#domainname.com</t:SmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:GetEvents>
<m:SubscriptionId>JwBhczhwcjA3bWI3OTI1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAS114Ai9w+UayiTSZLtc6DY6SxEJ7h9oIEAAAAAAAAAAAAAAAAAAAAAAAAAA=</m:SubscriptionId>
<m:Watermark>AQAAABTg+YC4KZFNttW01ElEHaecAgsrAAAAAAA=</m:Watermark>
</m:GetEvents>
</soap:Body>
</soap:Envelope>
</Trace>
26-8-2022 17:56:31 : EwsResponseHttpHeaders --- <Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2022-08-26 15:56:31Z">
HTTP/1.1 200 OK
Transfer-Encoding: chunked
request-id: de8811fe-8069-c2ff-15a7-5ac62e39d3f5
Alt-Svc: h3=":443",h3-29=":443"
X-CalculatedFETarget: AM6PR01CU002.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget: AS8PR07MB7925.eurprd07.PROD.OUTLOOK.COM
X-RUM-Validated: 1
x-ms-appId: fdea1aff-feaa-4d04-b795-55d873f2283b
Restrict-Access-Confirm: 1
x-EwsHandler: GetEvents
X-BeSku: WCS6
X-DiagInfo: AS8PR07MB7925
X-BEServer: AS8PR07MB7925
X-Proxy-RoutingCorrectness: 1
X-Proxy-BackendServerStatus: 200
X-FEProxyInfo: AM0PR02CA0136.EURPRD02.PROD.OUTLOOK.COM
X-FEEFZInfo: AMS
X-FEServer: AM6PR01CA0042,AM0PR02CA0136
X-FirstHopCafeEFZ: AMS
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Fri, 26 Aug 2022 15:56:28 GMT
Set-Cookie: exchangecookie=52d38d4eb5c14276b165655c6cd18691; path=/; secure
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
</Trace>
26-8-2022 17:56:31 : EwsResponse --- <Trace Tag="EwsResponse" Tid="1" Time="2022-08-26 15:56:31Z" Version="15.00.0913.015">
<?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="5588" MinorBuildNumber="3" 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:GetEventsResponse 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:GetEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notification>
<t:SubscriptionId>JwBhczhwcjA3bWI3OTI1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAS114Ai9w+UayiTSZLtc6DY6SxEJ7h9oIEAAAAAAAAAAAAAAAAAAAAAAAAAA=</t:SubscriptionId>
<t:PreviousWatermark>AQAAABTg+YC4KZFNttW01ElEHaecAgsrAAAAAAA=</t:PreviousWatermark>
<t:MoreEvents>false</t:MoreEvents>
<t:StatusEvent>
<t:Watermark>AQAAABTg+YC4KZFNttW01ElEHaf4BQsrAAAAAAE=</t:Watermark>
</t:StatusEvent>
</m:Notification>
</m:GetEventsResponseMessage>
</m:ResponseMessages>
</m:GetEventsResponse>
</s:Body>
</s:Envelope>
</Trace>
What could be the issue? Any suggestions are much appreciated!

Are there more the one Public Mailbox Folder doing the hosting, from what you describing it sounds like you create the subscription on the mailbox/cas that is hosting the hierarchy but the content is hosted on another public folder mailbox. A few thing to be aware of are
With Push and Pull notification they are hosted on a particular CAS server https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/getevents-operation
The SubscriptionID of the request is confirmed to be a valid subscription that is hosted on the Client Access server. If it is not, the GetEvents call fails.
So the first thing that might be happening is that routing of the request if failing. One thing you might want to do is compare the headers
X-CalculatedFETarget: AM6PR01CU002.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget:
From when you using Basic and it working to when you using the oAuth
The SMTP address of the authenticated user for the request is compared to the SMTP address of the user who created the subscription. If they do not match, the GetEvents request fails.
This is the other reason I could see it failing when using the client credentials flow. Impersonation from a Service Principal vs a User Principal maybe happening different on the back-end (could be bug). Probably the way to confirm that is test it using a Delegate that has a Mailbox and EWS Impersonation rights and use ROPC (or ever auth code flow) and see if the same thing happens.
These later thing should give different errors however.

Thanks for your help Glen.
I have one public folder mailbox with one public folder in it. (It's on office365 ofcourse.)
I am including the full trace of subscription and response at the bottom.
The subscription ID is the same in both the subscription as the getevents.
I am not getting an error that the subscription was not found. So I would think that the problem is not routing?
The headers are these for resp subscribing and polling:
CalculatedFETarget: AM6P193CU004.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget: AS8PR07MB7925.eurprd07.PROD.OUTLOOK.COM
CalculatedFETarget: AS8PR04CU007.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget: AS8PR07MB7925.eurprd07.PROD.OUTLOOK.COM
The CalculatedFETarget is different. Is this the hiarchy? Do you think this could be an issue?
This "Probably the way to confirm that is test it using a Delegate that has a Mailbox and EWS Impersonation rights and use ROPC (or ever auth code flow) and see if the same thing happens." is over my head.
In the current code, the account that is impersonated by the oAuth authenticated ExchangeService has application impersonation permissions and is listed as owner of the public folder.
I would like to emphasize that everything works fine for mailbox folders. In that case the owner/email address of the mailbox is impersonated by the oAuth authenticated ExchangeService.
"Impersonation from a Service Principal vs a User Principal maybe happening different on the back-end (could be bug)."
It could indeed be a bug. Do you know how a single person like me can still get access to Microsoft for this. One used to be able to raise a (paid) incident but now you need a prem. support contract to reach them.
========== subscription ==========
1-9-2022 12:57:13 : EwsRequestHttpHeaders --- <Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2022-09-01 10:57:13Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
X-AnchorMailbox: publicfolderstore_bac380fe#MyDomain.onmicrosoft.com
X-PublicFolderMailbox: publicfolderstore_bac380fe#MyDomain.onmicrosoft.com
X-PreferServerAffinity: true
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6InA5eWx3dnE4RW9zQzJMdjNCeklmYzZxTlh1bjVmQzl3QXAyWENGbG1QOVkiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbSIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2VkMDc0NDQxLWI4MjUtNDJjYy04ODU2LTE3YWUzYjBiMmY0Mi8iLCJpYXQiOjE2NjIwMjk1MjgsIm5iZiI6MTY2MjAyOTUyOCwiZXhwIjoxNjYyMDMzNDI4LCJhaW8iOiJFMlpnWUhob1p6K3ZvcFh0VnZWZklhK1ZvVEtWQUE9PSIsImFwc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25WqgI0tIGbqQoG_oQ
</Trace>
1-9-2022 12:57:13 : EwsRequest --- <Trace Tag="EwsRequest" Tid="1" Time="2022-09-01 10:57:13Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:SmtpAddress>UserAccount#Domain.com</t:SmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:Subscribe>
<m:PullSubscriptionRequest>
<t:FolderIds>
<t:FolderId Id="AQEuAAADTfhLNwPj+06PL1ijINAF1AEACMU9HL7QIUqU8ZZs9tXeAQAAAxYAAAA=" />
</t:FolderIds>
<t:EventTypes>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
</t:EventTypes>
<t:Timeout>90</t:Timeout>
</m:PullSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
</Trace>
1-9-2022 12:57:13 : EwsResponseHttpHeaders --- <Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2022-09-01 10:57:13Z">
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
request-id: 020ba111-367c-5403-10d0-edb4d8408dc5
X-CalculatedFETarget: AM6P193CU004.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget: AS8PR07MB7925.eurprd07.PROD.OUTLOOK.COM
X-RUM-Validated: 1
x-ms-appId: fdea1aff-feaa-4d04-b795-55d873f2283b
Restrict-Access-Confirm: 1
x-EwsHandler: Subscribe
X-BeSku: WCS6
X-DiagInfo: AS8PR07MB7925
X-BEServer: AS8PR07MB7925
X-Proxy-RoutingCorrectness: 1
X-Proxy-BackendServerStatus: 200
X-FEProxyInfo: AM3PR05CA0132.EURPRD05.PROD.OUTLOOK.COM
X-FEEFZInfo: AMS
X-FEServer: AM6P193CA0116,AM3PR05CA0132
X-FirstHopCafeEFZ: AMS
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Thu, 01 Sep 2022 10:57:10 GMT
Set-Cookie: exchangecookie=fae0cd80fcd944e9b2e3ac0e021b8dc8; path=/; secure
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
</Trace>
1-9-2022 12:57:13 : EwsResponse --- <Trace Tag="EwsResponse" Tid="1" Time="2022-09-01 10:57:13Z" Version="15.00.0913.015">
<?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="5612" MinorBuildNumber="5" 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:SubscribeResponse 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:SubscribeResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:SubscriptionId>JwBhczhwcjA3bWI3OTI1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAcX9pz2c1LEavlEM3OLE6OTYrWLgIjNoIEAAAAAAAAAAAAAAAAAAAAAAAAAA=</m:SubscriptionId>
<m:Watermark>AQAAABTg+YC4KZFNttW01ElEHadDSGwrAAAAAAA=</m:Watermark>
</m:SubscribeResponseMessage>
</m:ResponseMessages>
</m:SubscribeResponse>
</s:Body>
</s:Envelope>
</Trace>
============= get events ==============
1-9-2022 13:00:23 : EwsRequestHttpHeaders --- <Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2022-09-01 11:00:23Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
X-AnchorMailbox: publicfolderstore_bac380fe#MyDomain.onmicrosoft.com
X-PublicFolderMailbox: publicfolderstore_bac380fe#MyDomain.onmicrosoft.com
X-PreferServerAffinity: True
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6InA5eWx3dnE4RW9zQzJMdjNCeklmYzZxTlh1bjVmQzl3QXAyWENGbG1QOVkiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbSIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2VkMDc0NDQxLWI4MjUtNDJjYy04ODU2LTE3YWUzYjBiMmY0Mi8iLCJpYXQiOjE2NjIwMjk1MjgsIm5iZiI6MTY2MjAyOTUyOCwiZXhwIjoxNjYyMDMzNDI4LCJhaW8iOiJFMlpnWUhob1p6K3ZvcFh0VnZWZklhK1ZvVEtWQUE9PSIsImFwcF9kaXNwbGF5bmFtZSI6IkV4Y2hhbmdlR3JvdXBDYWxlbmRhciIsImFwcGlkIjoiZmRlYTFhZmYtZmVhYS00ZDA0LWI3OTUtNTVkODczZjIyODNiIiwiYXBwaWRhY3IiOiIxIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvZWQwNzQ0NDEtYjgyNS00MmNjLTg4NTYtMTdhZTNiMGIyZjQyLyIsIm9pZCI6IjM4MDkxNzg0LWU5NzItNDk4ZS05ZTlkLTZmMGE2NzQ4MTMyZSIsInJoIjoiMC5BVThBUVVRSDdTVzR6RUtJVmhldU93c3ZRZ0lBQUFBQUFQRVB6Z0FBQUFBQUFBQlBBQUEuIiwicm9sZXMiOlsiZnVsbF9hY2Nlc3NfYXNfYXBwIl0sInNpZCI6IjE1MzQ5NThhLThmYjYtNDg4Ny05ZWU0LWFkZDM2ZGQ4ZDVlYyIsInN1YiI6IjM4MDkxNzg0LWU5NzItNDk4ZS05ZTlkLTZmMGE2NzQ4MTMyZSIsInRpZCI6ImVkMDc0NDQxLWI4MjUtNDJjYy04ODU2LTE3YWUzYjBiMmY0MiIsInV0aSI6InZtR2ZDS0ZSWTBPS2R2OTVaU0Z1QUEiLCJ2ZXIiOiIxLjAiLCJ3aWRzIjpbIjA5OTdhMWQwLTBkMWQtNGFjYi1iNDA4LWQ1Y2E3MzEyMWU5MCJdfQ.IlPfIOgl6H7Kenn999w6GPrHjPKyT_T_JLxSQc2w1Pjs8W_W4_brehe_wVX8YdqQPLEOo4fYX9l3gHHZeXtuOkgir1hM9w6TomM_FP6vBTeuGjVe7xLL0fSPvAd63pwvQicCj7SbX-RQBpvKeAapf5zA70UOYfo_NKic_ErJSWoYkSvDDX67LipjQrZ68X8XQQe3z_U7PfbwKABY91twQftzI4WXbQoRcEv8AgCQ9dxhFTIJgdzeV6slf-vnPHQ2Ic2bSnHpIJRGW-TV3o7zb6eRkTib1xs6SDBd3PIWAZoEz-uQbJ1MXwUEETfcDLNGkGYk25WqgI0tIGbqQoG_oQ
</Trace>
1-9-2022 13:00:23 : EwsRequest --- <Trace Tag="EwsRequest" Tid="1" Time="2022-09-01 11:00:23Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:SmtpAddress>UserAccount#Domain.com</t:SmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:GetEvents>
<m:SubscriptionId>JwBhczhwcjA3bWI3OTI1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAcX9pz2c1LEavlEM3OLE6OTYrWLgIjNoIEAAAAAAAAAAAAAAAAAAAAAAAAAA=</m:SubscriptionId>
<m:Watermark>AQAAABTg+YC4KZFNttW01ElEHadDSGwrAAAAAAA=</m:Watermark>
</m:GetEvents>
</soap:Body>
</soap:Envelope>
</Trace>
1-9-2022 13:00:23 : EwsResponseHttpHeaders --- <Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2022-09-01 11:00:23Z">
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
request-id: 614cb84b-af3f-c278-0910-971429e39c7b
X-CalculatedFETarget: AS8PR04CU007.internal.outlook.com
X-BackEndHttpStatus: 200,200
X-CalculatedBETarget: AS8PR07MB7925.eurprd07.PROD.OUTLOOK.COM
X-RUM-Validated: 1
x-ms-appId: fdea1aff-feaa-4d04-b795-55d873f2283b
Restrict-Access-Confirm: 1
x-EwsHandler: GetEvents
X-BeSku: WCS6
X-DiagInfo: AS8PR07MB7925
X-BEServer: AS8PR07MB7925
X-Proxy-RoutingCorrectness: 1
X-Proxy-BackendServerStatus: 200
X-FEProxyInfo: AM4P190CA0002.EURP190.PROD.OUTLOOK.COM
X-FEEFZInfo: AMS
X-FEServer: AS8PR04CA0209,AM4P190CA0002
X-FirstHopCafeEFZ: AMS
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Thu, 01 Sep 2022 11:00:20 GMT
Set-Cookie: exchangecookie=fae0cd80fcd944e9b2e3ac0e021b8dc8; path=/; secure
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
</Trace>
1-9-2022 13:00:23 : EwsResponse --- <Trace Tag="EwsResponse" Tid="1" Time="2022-09-01 11:00:23Z" Version="15.00.0913.015">
<?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="5612" MinorBuildNumber="5" 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:GetEventsResponse 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:GetEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notification>
<t:SubscriptionId>JwBhczhwcjA3bWI3OTI1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAcX9pz2c1LEavlEM3OLE6OTYrWLgIjNoIEAAAAAAAAAAAAAAAAAAAAAAAAAA=</t:SubscriptionId>
<t:PreviousWatermark>AQAAABTg+YC4KZFNttW01ElEHadDSGwrAAAAAAA=</t:PreviousWatermark>
<t:MoreEvents>false</t:MoreEvents>
<t:StatusEvent>
<t:Watermark>AQAAABTg+YC4KZFNttW01ElEHafKVmwrAAAAAAE=</t:Watermark>
</t:StatusEvent>
</m:Notification>
</m:GetEventsResponseMessage>
</m:ResponseMessages>
</m:GetEventsResponse>
</s:Body>
</s:Envelope>
</Trace>

Related

Curl POST request to Mulesoft HTTP Request

Looking to implement in following into Mulesoft HTTP request
curl "https://somedomain.com/1/1/1/search"
-X POST
-H "Authorization: Bearer token"
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<flow name="MyRequestFlow" doc:id="04948f48-2508-4f1c-83fe-ea899886a61c" >
<http:request method="POST" doc:name="Request" doc:id="bd921beb-2142-4c24-be1d-c174e994c982" url="https://somedomain.com/1/1/1/search">
<http:headers ><![CDATA[#[output application/java
---
{
"Authorization" : "Bearer token"
}]]]></http:headers>
</http:request>
</flow>
</mule>

How to properly create/update public folder via EWS using admin impersonation?

I cannot create any public folder in case when I set proper permission (through WebUI) to that user (in my case admin).
But when I try to update public folder`s 'EffectiveRights' to add permission level to that user I cannot do it. Which request I need to send to update user permission level on public folder or add proper 'EffectiveRights' on that public folder?
Example of the request:
POST outlook.office365.com/EWS/Exchange.asmx
Content-Type:text/xml; charset=utf-8
Accept:text/xml; charset=utf-8
BODY
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>test#test_test.onmicrosoft.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<UpdateFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<FolderChanges>
<t:FolderChange>
<t:DistinguishedFolderId Id="publicfoldersroot" />
<t:Updates>
<t:SetFolderField>
<t:FieldURI FieldURI="folder:EffectiveRights"/>
<t:Folder>
<t:EffectiveRights>
<t:CreateAssociated>false</t:CreateAssociated>
<t:CreateContents>true</t:CreateContents>
<t:CreateHierarchy>false</t:CreateHierarchy>
<t:Delete>false</t:Delete>
<t:Modify>false</t:Modify>
<t:Read>true</t:Read>
</t:EffectiveRights>
</t:Folder>
</t:SetFolderField>
</t:Updates>
</t:FolderChange>
</FolderChanges>
</UpdateFolder>
</soap:Body>
</soap:Envelope>
and the response is:
<?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="1164" MinorBuildNumber="25" 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:UpdateFolderResponse 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:UpdateFolderResponseMessage ResponseClass="Error">
<m:MessageText>Set action is invalid for property.</m:MessageText>
<m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:MessageXml>
<t:FieldURI FieldURI="folder:EffectiveRights"/>
</m:MessageXml>
<m:Folders/>
</m:UpdateFolderResponseMessage>
</m:ResponseMessages>
</m:UpdateFolderResponse>
</s:Body>
</s:Envelope>
another one example:
POST outlook.office365.com/EWS/Exchange.asmx
Content-Type:text/xml; charset=utf-8
Accept:text/xml; charset=utf-8
BODY
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>test#test_test.onmicrosoft.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:UpdateFolder>
<m:FolderChanges>
<t:FolderChange>
<t:FolderId Id="AAEuAAAAAAAaRHOQqmYRzZvIAKoAL8RaAwCOXNGsJPKoS5iTrqfBNvbzAACDSr4rAAA=" />
<t:Updates>
<t:SetFolderField>
<t:FieldURI FieldURI="folder:PermissionSet" />
<t:Folder>
<t:PermissionSet>
<t:Permissions>
<t:Permission>
<t:UserId>
<t:PrimarySmtpAddress>test#test_test.onmicrosoft.com</t:PrimarySmtpAddress>
</t:UserId>
<t:PermissionLevel>Editor</t:PermissionLevel>
</t:Permission>
</t:Permissions>
</t:PermissionSet>
</t:Folder>
</t:SetFolderField>
</t:Updates>
</t:FolderChange>
</m:FolderChanges>
</m:UpdateFolder>
</soap:Body>
</soap:Envelope>
and the response:
<?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="1143" MinorBuildNumber="18" 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:UpdateFolderResponse 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:UpdateFolderResponseMessage ResponseClass="Error">
<m:MessageText>Access is denied. Check credentials and try again., Underlying MAPI stream threw exception</m:MessageText>
<m:ResponseCode>ErrorAccessDenied</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Folders/>
</m:UpdateFolderResponseMessage>
</m:ResponseMessages>
</m:UpdateFolderResponse>
</s:Body>
</s:Envelope>
Because your trying to create folders in publicfoldersroot no user has rights by default to do that (this is to stop people messing up the Public Folder root). So if you want your user test#test_test.onmicrosoft.com you would need to first grant them rights to do that on the Root folder either using the EAC or Add-PublicFolderclientPermissions. I would suggest you first create a folder in the Root using the EAC and then get your code to create child folders of that, from a development point of view this is easier to cleanup when you need to delete everything and test again then trying to clear the whole root hierarchy each time.
Also only you second example will work because EffectiveRights is a calculate property so can't be updated, all you can do is update the underlying DACL of the folder which is what you second request is doing

Outlook Web Addin - get SMTP details

Is there a way to get the SMTP details of the current mail from an Outlook web addin? I see that the VSTO addin has this.
I got all the mime data through this
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:BaseShape>Default</t:BaseShape>
<t:IncludeMimeContent>true</t:IncludeMimeContent>
</ItemShape>
<ItemIds>
<t:ItemId Id=" item_id "/>
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
The mime data can then be decoded to get more details about the message

The number of entities returned by this export request has exceeded the maximum allowed taleo

I am attempting to fetch data from Taleo Enterprise SOAP API
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:itk="http://www.taleo.com/ws/integration/toolkit/2011/05/management"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>
<itk:getLargeDocumentByKey><messageKey>124110901</messageKey>
</itk:getLargeDocumentByKey></soap:Body></soap:Envelope>
and I get an error the number of entities returned by this export request (787026) has exceeded the maximum allowed (100000).
------=_Part_99112_1948897443.1507649297078
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <soap.xml#xfire.codehaus.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns1:getLargeDocumentByKeyResponse xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2011/05/management">
<ns1:Document xmlns:ns2="http://www.w3.org/2004/11/xmlmime" ns2:contentType="text/xml; charset=UTF-8">
<Include xmlns="http://www.w3.org/2004/08/xop/include" href="cid:1507649297078209382008132646#http://www.w3.org/2001/XMLSchema"/>
</ns1:Document></ns1:getLargeDocumentByKeyResponse></soap:Body>
</soap:Envelope>
------=_Part_99112_1948897443.1507649297078
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-ID: <1507649297078209382008132646#http://www.w3.org/2001/XMLSchema>
<Document xmlns="http://www.taleo.com/ws/integration/toolkit/2011/05">
<Attributes><Attribute name="count">0</Attribute>
<Attribute name="duration">0:00:00.790</Attribute>
<Attribute name="mode">T-XML</Attribute>
<Attribute name="version">http://www.taleo.com/ws/tee800/2009/01</Attribute></Attributes>
<Content><ExportErrors><Error>
<Code>ServerError</Code><Subcode>itk:ExportTooManyRecords</Subcode>
<Reason>The number of entities returned by this export request (787026) has exceeded the maximum allowed (100000).</Reason></Error></ExportErrors>
</Content></Document>
------=_Part_99112_1948897443.1507649297078--
Is there any way to split or limit of the export. Any help is much appreciated.
Thank you.

Recurring Appointment: no error, not visible

I am creating a recurring appointment via EWS managed API.
Creating Weekly appointments works.
Creating Monthly Appointments doesn't work.
When EWS posts my monthly appointment to the server, Exchange does not return any error, yet the appointment is not there.
All I can see, it should be there - but it isn't!
Does anyone here know why?
Here is the trace of the recurrence posted to the server:
<t:Recurrence>
<t:RelativeMonthlyRecurrence>
<t:Interval>1</t:Interval>
<t:DaysOfWeek>Saturday</t:DaysOfWeek>
<t:DayOfWeekIndex>Last</t:DayOfWeekIndex>
</t:RelativeMonthlyRecurrence>
<t:NumberedRecurrence> <br /> <t:StartDate>2014-04-26</t:StartDate>
<t:NumberOfOccurrences>10</t:NumberOfOccurrences>;
</t:NumberedRecurrence>
</t:Recurrence>
and here is the trace of the response header
<Trace Tag="EwsResponseHttpHeaders" Tid="18" Time="2014-04-25 14:00:56Z">
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
X-EwsPerformanceData: RpcC=13;RpcL=919;LdapC=0;LdapL=0;
Persistent-Auth: true
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Fri, 25 Apr 2014 14:00:56 GMT
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
</Trace>
and the response body.
<Trace Tag="EwsResponse" Tid="18" Time="2014-04-25 14:00:56Z" Version="15.00.0516.014"> <br /> <?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success"> r /> <m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkADZmMGNlYzkwLWE0NGUtNGQxMC04MTc4LTE3MWM3MzExM2UzMQBGAAAAAAAVFLM1uwjxTpI7ZWapZLFDBwAG/DdYA3s2SJJPro446HsmAAAAAAAgAAAG/DdYA3s2SJJPro446HsmAAAOswdMAAA=" ChangeKey="DwAAABYAAAAG/DdYA3s2SJJPro446HsmAAAOsyvo" />
</t:CalendarItem>
</m:Items>
</m:CreateItemResponseMessage>
</m:ResponseMessages> r /> </m:CreateItemResponse>
</s:Body>
</s:Envelope>
</Trace>
Given that your XML is invalid, no surprise:
<t:DaysOfWeek>Saturday</t:DaysOfWeek>
^^^^---- should be just <
<t:DayOfWeekIndex>Last</t:DayOfWeekIndex>
^^^^----ditto
<t:NumberedRecurrence> <br /> <t:StartDate>2014-04-26</t:StartDate>
^^^^^^---huh? ^^^^----ditto

Resources