Send chat message to teams user from another teams user from application

GP 41 Reputation points
2022-10-27T16:27:15.663+00:00

I need to send messages to teams users from an application (C#) on behalf of one user. this sender user also has teams account.
The appregistration is created by Admin user who do not have the teams, We have added the teams user (who is sender) to this app registration users list.

Given API permissions:
Delegated:
Chat.ReadWrite, User.Read, ChannelMessage.Send, ChatMessage.Send, ChatMessage.Read

Application:
User.Read.All, Chat.Read.All, Chat.ReadWrite.All, Chat.Create

one to one chat.

Getting below exception:
Microsoft.Graph.ServiceException: 'Code: PreconditionFailed
Message: Requested API is not supported in application-only context

Could you please advice on this? Please provide a solution for this.
Thanks in advance

Microsoft Security | Microsoft Graph
Microsoft Teams | Microsoft Teams for business | Other
0 comments No comments

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,831 Reputation points
    2022-10-28T02:58:31.953+00:00

    Hello @GeedulaPrashanthiGTIS-1367

    Thanks for reaching out!

    Based on my research, currently Graph API doesn't support sending message on behalf of other users (without a signed-in user presence)
    Please refer to this documentation for more details.

    Hope this helps.

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

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    3 deleted comments

    Comments have been turned off. Learn more

Your answer

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