How to send a teams 1-1 message from ms graph

Vagelis Dermos 0 Reputation points

Hi to all,

i want to send a teams 1-1 message chat.

the steps i did so far.

  1. login from with clint id/secret scope=>
  2. create 1-1 chat
    { "chatType":"oneOnOne", "members":[ { "@odata.type":"#microsoft.graph.aadUserConversationMember", "roles":["owner"], "user@odata.bind": "'7........f')" }, { "@odata.type":"#microsoft.graph.aadUserConversationMember", "roles":["owner"], "user@odata.bind": "'9........3')" } ] }

From the response, i take the "id" and post as :

  "body": {
     "content": "Hello world"

but i take an error about migration

    "error": {
        "code": "Unauthorized",
        "message": "Message POST is allowed in application-only context only for import purposes. Refer to for more details.",
        "innerError": {
            "date": "2024-03-14T13:27:32",
            "request-id": "efee9ffb-28a6-4ffe-a398-57adec529133",
            "client-request-id": "efee9ffb-28a6-4ffe-a398-57adec529133"

In azure portal i have add several rights but no luck:
User's image

What am i missing?

Can anyone help me?

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,013 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,485 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LiweiTian-MSFT 13,665 Reputation points Microsoft Vendor

    Hi @Vagelis Dermos

    Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description, your question is related to Graph API, which is not in our support scope. The following suggestion is just for your reference:

    Send chat messages in channels or chats using Graph

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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. *********************************************************************************************************