Message POST is allowed in application-only context only for import purposes

Nirmallya Ghosh 20 Reputation points
2023-05-30T04:25:23.9633333+00:00

I am trying to send message to teams Channel but i am getting below error -

Can anyone please help ?

RESPONSE -


{
    "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": "2023-05-30T04:07:23",
            "request-id": "14e70f9f-46f4-45dc-99ab-2bb0094ded3f",
            "client-request-id": "14e70f9f-46f4-45dc-99ab-2bb0094ded3f"
        }
    }
}

ACCESS TOKEN -


curl --location 'https://login.microsoftonline.com/64c0b******c-99c6-e***ac44/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=8c4d5231-e***********3f8e1d9c' \
--data-urlencode 'scope=https://graph.microsoft.com/.default' \
--data-urlencode 'client_secret=VfS8************n2PLhcqjcRC' \
--data-urlencode 'grant_type=client_credentials'

cURL for Sending Message to Teams Channel -

curl --location 'https://graph.microsoft.com/v1.0/teams/0c1a5839**********-abdd-bb5772cf50ee/channels/1**********c7872b9bb@thread.tacv2/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer accessToken
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,894 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.
3,895 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,341 Reputation points
    2023-05-30T05:50:34.6933333+00:00

    Hi @Nirmallya Ghosh

    Application permissions are only supported for migration, which means you need to use application permissions to create a team and channel in a migration state, and then import third-party platform messages into the team.

    If your context is just sending chat messages in a channel, then use delegated permissions instead.

    User's image

    Hope this helps.

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

    1 person found this answer helpful.

  2. Suryadi Uganda 0 Reputation points
    2025-03-24T09:29:00.9066667+00:00

    {"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":"2025-03-24T09:23:35","request-id":"bbe089bf-b515-4a0c-8be4-580137ddf39d","client-request-id":"bbe089bf-b515-4a0c-8be4-580137ddf39d"}}}

    if i have to subscribe something in microsoft to enable API send chat with teams, which subject or title of subsribe ? and which permissions i have to enabled ?


Your answer

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