Unable to Post message to teams channel using Application permission

Anonymous
2022-01-25T11:09:55.147+00:00

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

  1. Is it possible to send the message to team->channel->message using application permission ? if yes how to resolve the above error?
  2. 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

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,047 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,557 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,836 questions
{count} votes

Accepted answer
  1. Ramjot Singh 861 Reputation points Microsoft Employee
    2022-01-26T08:06:30.303+00:00

    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.


0 additional answers

Sort by: Most helpful