Search code examples
office365exchangewebservicesews-managed-api

Mapping ID of Calendars as returned from Office 365 REST API to that returned by EWS API


I am trying to find a way to map/convert the Id returned from Office 365 REST API (GET /calendars) to the Ids returned from EWS (list folders on DistinguishedFolderId="calendar") or vice-versa.

I have noticed that for same calendar the Id returned from Office 365 API differs to that returned from EWS API.

Office 365 API - 
"AAMkADRlYTIyZTNiLWQ1ZjQtNGQwOS1hOGYzLTFjY2NkYzM4MzA2NwBGAAAAAAAhWNzR1hCyToyWVDoyJaPGBwAPTshXMc1wTqPkmdHO8phYAAAAAAEGAAAPTshXMc1wTqPkmdHO8phYAAB-AHbjAAA="

EWS API - 
"AAMkADRlYTIyZTNiLWQ1ZjQtNGQwOS1hOGYzLTFjY2NkYzM4MzA2NwAuAAAAAAAhWNzR1hCyToyWVDoyJaPGAQAPTshXMc1wTqPkmdHO8phYAAB/AHL6AAA="

I am unable to figure out a way for associating both. I want to have a clear mapping/conversion between these.

Edit 1: It turns out that, Id returned from Office 365 REST API when used on EWS(after replacing '-' with '/' and '_' with '+'), corresponds to a Item of type 'Message' under some 'Common Views' folder. This looks to be a strange design. Is the replacement mentioned above sufficient? Or there are other characters that should be replaced?

P.S:

  1. I have already referred to http://stackoverflow.com/questions/30082306/mapping-office365-rest-calendar-ids-to-ews-calendaritem-ids, but it does not work in my case(as the length of the Ids are different).
  2. I have seen this doc on ConvertId operation. But I am unable to understand how to apply it in this case. Because the Id I am using "RequestServerVersion Version="Exchange2010" which should be the version for Office 365 API also.

Solution

  • I have found a way for mapping/associating the Ids of calendars returned from Office 365 REST and EWS API.

    Use EWS GET Folder API with DistinguishedFolderId="calendar" to get the folder id of calendar. Call EWS list folders API to get all other calendars on Exchange.

    Now, mapping these Ids to that returned from Office 365: For each calendar returned above, call Office 365 REST API(/calendar/{id}). This API returns corresponding calendar from Office 365 with a new Id(i.e. Office 365 identifier for the same). Interestingly, this Id corresponds to a message item under "Common Views" folder on EWS.

    Although, it works through trial I am unable to find any MS document explaining this.

    Does anyone have any idea about this behaviour?