Converting restId format type to old Outlook HexEntryId type

203 Views Asked by At

Back in the days when we did a calendar synchronisatie via Outlook this gave us IDs of the form:

00000000ABC72AACB341FF4F9886BAAC125E772807007591CF0335B23144ADC7FCD71BA6E2FC00000000010D00007591CF0335B23144ADC7FCD71BA6E2FC00009957CF160000

We later upgraded the code to use Exchange Web Services, and for a smooth transistion we kept the old IDs in custom event properties, and therefore had to convert EWS EntryIds like this:

<soapenv:Body>
  <mes:ConvertId DestinationFormat="HexEntryId">
    <mes:SourceIds>
      <typ:AlternateId Format="EwsId" Id="AAMkADI2ZGIwY2FlLTA1NDQtNGFhYi1hNDJmLWEyMGJhZWU5NmM2YgBGAAAAAACrxyqss0H/T5iGuqwSXncoBwB1kc8DNbIxRK3H/NcbpuL8AAAAAAENAAB1kc8DNbIxRK3H/NcbpuL8AAJ2Kv4fAAA=" Mailbox="[email protected]"/>
    </mes:SourceIds>
  </mes:ConvertId>
</soapenv:Body>

Response:

 <ResponseMessages>
   <ConvertIdResponseMessage ResponseClass="Success">
     <ResponseCode>NoError</ResponseCode>
     <AlternateId type="t:AlternateIdType" Format="HexEntryId" Id="00000000ABC72AACB341FF4F9886BAAC125E772807007591CF0335B23144ADC7FCD71BA6E2FC00000000010D00007591CF0335B23144ADC7FCD71BA6E2FC0002762AFE1F0000" Mailbox="[email protected]"/>
   </ConvertIdResponseMessage>
 </ResponseMessages>

We are now moving to MS Graph and I need to be able to convert the new restId format to the old Outlook ones using translateExchangeIds (according to Exchange Web Services (EWS) to Microsoft Graph API mappings).
But there is no such thing as the HexEntryId format type. I tried several combinations with no luck.

(How) can I convert the MS Graph REST IDs to these HexEntryId?

1

There are 1 best solutions below

0
On BEST ANSWER

I think that you need to first convert restId to entryId by calling

POST /me/translateExchangeIds

{
    "inputIds": [
        "{restId}"
    ],
    "sourceIdType": "restId",
    "targetIdType": "entryId"
}

It will return targetId in form of entryId.

Now convert entryId to hexEntryId

  • Take targetId and remove an integer from the end of the string. This integer indicates how many characters = must be added to the end of the string.
  • Add = at the end of the string (how many times - from previous step)
  • Replace _ with /
  • Replace - with +
  • Convert string from base64 to byte array
  • Convert byte array to hex string

The final hex string should be your hexEntryId