Sending message in application context is ONLY supported when migration is in process. This is listed in the docs at https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http#permissions. You can use bot to send a message in application context. Graph will not send you a bot token. Please refer to Bot documentation https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conversations on how to send messages.
Unable to Post message to teams channel using Application permission
Hi,
I've subscribed to team channel message using subscription api and i'm getting event for message but when i receive the event i want to post a message back to teams or update the same message i got a token using client credentials flow because i don't want to send message on user behalf.
But i'm unable to send message using application permission it give me the following error
{
"error": {
"code": "Forbidden",
"message": "Missing role permissions on the request. API requires one of 'Teamwork.Migrate.All, ChannelMessage.ReadWrite.All'. Roles on the request ''.",
"innerError": {
"date": "2022-01-25T09:19:59",
"request-id": "1b9d16cc-c40b-4c6a-8305-c6ca96983fd3",
"client-request-id": "1b9d16cc-c40b-4c6a-8305-c6ca96983fd3"
}
}
}
though I've the Teamwork.Migrate.All app permission
Question
- Is it possible to send the message to team->channel->message using application permission ? if yes how to resolve the above error?
- If not possible is there any other way which can achieve the following:
I got an event for any message sent in the team channel and then i can reply or update the message using something like bot token ?
I know delegated permission is working but i don't want it on user behalf.
Thanks
-
Ramjot Singh 861 Reputation points Microsoft Employee
2022-01-26T08:06:30.303+00:00