0
votes

Context I am using: office-js (retrieve rest ID of message item), java backend (using GraphClient to get the immutable ID, subscription webhook endpoint)

When I get the rest itemId of the draft item via office-js like this:

Office.context.mailbox.item.saveAsync((asyncResult) => {
        if (asyncResult.error) {
            //hadle
        } else {
          resolve(
              Office.context.mailbox.convertToRestId
                   (
                     asyncResult.value, 
                     Office.MailboxEnums.RestVersion.v1_0
                   )
          );
        }
});

I send it to the backend where I translate it to Immutable ID, via GraphClient, that I save. Once I get a notification on my subscription endpoint (I change and save the subject of the message draft in outlook), it is successfully paired.

Problem is when I send the draft from outlook. I get notification to the subscription enpoint, but it has a different immutable ID. I create subscriptions with Prefer header like this:

Subscription subscription = new Subscription();
        subscription.changeType = "updated";
        subscription.notificationUrl = notificationUrl;
        subscription.resource = resource;
        subscription.expirationDateTime = OffsetDateTime.now().plusDays(2);
        subscription.clientState = secret;
        subscription.latestSupportedTlsVersion = "v1_2";

        SubscriptionCollectionRequest request = graphServiceClient.subscriptions().buildRequest();
        if(request != null) {
            request.addHeader("Prefer", "IdType=\"ImmutableId\"");
            request.post(subscription);
        } else {

Is there anything I am doing wrong? Draft is move to the "Sent items" folder, which should not change immutable ID (https://docs.microsoft.com/en-us/graph/outlook-immutable-id).

Ids looks like this AAkALgAAA.........yACqAC-EWg0AC.......7B4s_RdwAA....TwAA I suppose they are correct. Just last section after underscore changes on draft sent.

1

1 Answers

1
votes

Not surprising at all - it is a physically different message. Just the way Exchange works - sent/unsent flag cannot be flipped after the message is saved, so a new message is created in the Sent Items folder.