Search code examples
c#azuremicrosoft-graph-apimicrosoft-graph-sdksmicrosoft-graph-teams

Can't send messages in Channel through Client credentials provider flow - Microsoft Graph API


I'm trying to send a message in Microsoft Teams Channel via Client credentials provider flow. But it gives the following error.

enter image description here

I've followed the documentation here.

POST /teams/{id}/channels/{id}/messages

This is how my API Permissions look like. enter image description here

I'm not sure if we can send messages on the channel through the application. Because I don't want to send it via delegated way. Is there any way we can achieve this?

UPDATE: This is how I'm generating the token. enter image description here

Update 2: screenshot of the postman request.

enter image description here


Solution

  • Generally speaking, you missed "Bearer " in Authorization header.

    enter image description here

    But based on my test, although we add Group.ReadWrite.All and Teamwork.Migrate.All Application permission, it will still give 401 Unauthorized error.

    After a research, I find that the use case of Application mode is to Import third-party platform messages to Teams using Microsoft Graph.

    See the examples here.

    I'm afraid that we have to use delegated way to send messages to Teams channel.