Error: Exchange workload is not enabled for rich notifications

Ayemi Musa 0 Reputation points
2023-05-25T21:29:21.3+00:00

Trying to create MS Graph notification subscription with the following settings:

 final var subscriptionRequest = new Subscription();
 subscriptionRequest.changeType = ChangeType.CREATED.toString();
 subscriptionRequest.notificationUrl = notificationHost + "/notification/listen";
 subscriptionRequest.lifecycleNotificationUrl = notificationHost + "/notification/lifecycle";

 subscriptionRequest.resource = 
"users/00f2dc3e-2858-4c93-8c5e-afeff10a7a34/mailfolders('inbox')/messages?$select=Subject,bodyPreview,receivedDateTime,from,to"; 
 subscriptionRequest.clientState = UUID.randomUUID().toString();
 subscriptionRequest.includeResourceData = true;
 subscriptionRequest.encryptionCertificate = certificateStore.getBase64EncodedCertificate();
 subscriptionRequest.encryptionCertificateId = certificateStore.getCertificateId();
 subscriptionRequest.expirationDateTime = OffsetDateTime.now().plusMinutes(10);

But I am getting the following error:

2023-05-25 22:04:55,200 INFO  [com.azu.ide.ClientSecretCredential] (ForkJoinPool.commonPool-worker-11) Azure Identity => getToken() result for scopes [https://graph.microsoft.com/.default]: SUCCESS

2023-05-25 22:04:57,086 SEVERE [global] (OkHttp https://graph.microsoft.com/...) CoreHttpProvider[lambda$sendRequestAsyncInternal$0] - 384Graph service exception

2023-05-25 22:04:57,088 SEVERE [global] (OkHttp https://graph.microsoft.com/...) Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: InvalidRequest

Error message: Exchange workload is not enabled for rich notifications.

POST https://graph.microsoft.com/v1.0/subscriptions

SdkVersion : graph-java/v5.58.0

SdkVersion : graph-java/v5.58.0

[...]

400 : Bad Request

[...]

[Some information was truncated for brevity, enable debug logging for more details]

2023-05-25 22:04:57,124 ERROR [gra.tes.GraphStarter] (OkHttp https://graph.microsoft.com/...) java.util.concurrent.CompletionException: com.microsoft.graph.http.GraphServiceException: Error code: InvalidRequest

Error message: Exchange workload is not enabled for rich notifications.

Kindly assist to unravel the cause.

Thank you

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,646 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ayemi Musa 0 Reputation points
    2023-05-26T12:30:52.41+00:00

    Problem solved!

    Solution:

    In order to call the beta API, you must install the Microsoft Graph Beta Java SDK

    https://learn.microsoft.com/en-us/graph/sdks/use-beta?tabs=Java

    Add the dependency in dependencies in pom.xml
    
    <dependency>
      <!-- Include the sdk as a dependency -->
      <groupId>com.microsoft.graph</groupId>
      <artifactId>microsoft-graph-beta</artifactId>
      <version>0.73.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <!-- This dependency is only needed if you are using the TokenCrendentialAuthProvider -->
      <groupId>com.azure</groupId>
      <artifactId>azure-identity</artifactId>
      <version>1.2.5</version>
    </dependency>
    Add the repository in repositories in pom.xml
    
    <repository>
      <id>sonatype-snapshot</id>
      <name>Sonatype Snapshot</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
    

    More details:

    The current version of Graph 1.0 does not support rich notification for Messages. See link below:

    https://learn.microsoft.com/en-us/graph/webhooks-with-resource-data

    Available in only the beta endpoint:

    New or changed personal contacts in a user's mailbox: /users/{id}/contacts

    New or changed personal contacts in a user's contactFolder: /users/{id}/contactFolders/{id}/contacts

    New or changed events in a user's mailbox: /users/{id}/events

    New or changed messages in a user's mailbox: /users/{id}/messages

    New or changed messages in a user's mailFolder: /users/{id}/mailFolders/{id}/messages

    Teams Meeting status information updates: /communications/onlineMeetings/?$filter=JoinWebUrl eq '{joinWebUrl}

    New or changed members in all channels across the entire tenant: /teams/getAllChannels/getAllMembers

    0 comments No comments