The CreatorCon Call for Content is officially open! Get started here.

Make new action and Send Message to Teams channel using Microsoft Graph API

KellyLewins
Tera Expert

Hi!

am trying to send message to Teams Channel using Microsoft Graph API "/channels/{channel-id}/messages".

https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http

I have made Application in Azure portal and added "ChannelMessage.Send" permissions.(Delegated)

 

The connection is succeeded but I cannot fix 401 Error bellow.

 

Status Code : 401

Response Body :

 

{"error":{"code":"Unauthorized","message":"Message POST is allowed in application-only context only for import purposes. Refer to https://docs.microsoft.com/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams for more details.","innerError":{"date":"2024-07-25T11:07:26","request-id":"my-requestid","client-request-id":"my-clientrequestid"}}}

 

 

1 ACCEPTED SOLUTION

KellyLewins
Tera Expert

Solved by changing Grant type "Client Credentials" to "Authorization Code"!

Thank you.

View solution in original post

1 REPLY 1

KellyLewins
Tera Expert

Solved by changing Grant type "Client Credentials" to "Authorization Code"!

Thank you.