How to send activity feed notification to a user in another tenant using Graph API with Java

Test 0 Reputation points
2024-05-24T20:32:08.41+00:00

Hi!

I'm developing a server application with Java and I want to send an activity feed notification to a user who is not in my tenant through our Teams personal app. To achieve this, I created a GraphServiceClient with Client Credentials Provider, following this tutorial: https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=java#client-credentials-provider

I was able to create the Graph client with client credentials. However, when I tried to send the notification using the following code:

graphClient.users().byUserId(userId).teamwork().sendActivityNotification().post(sendActivityNotificationPostRequestBody);

I received an error stating that "user id 'xxxx-xxxx-xxx' is in the tenant". How can I send a notification to a user that is not in my tenant using the Graph API with Java?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,910 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 41,371 Reputation points
    2024-05-27T03:10:42.8466667+00:00

    Hi @Test

    You can't send activity feed notifications to users in other tenants.

    You must add the target user as a guest to your tenant. Or configure your app as a multi-tenant app, and then add your multi-tenant app as an enterprise app to the tenant where the target users are located.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.