Error "The caller must be one of the members specified in request body" when creating one-on-one chat

Ruben 0 Reputation points
2024-11-20T09:45:06.35+00:00

I'm encountering an issue while attempting to create a one-on-one chat in Microsoft Teams using the Microsoft Graph API. Here's the error response I'm receiving:

"code": "BadRequest", "message": "The caller must be one of the members specified in request body."  

I'm using the Microsoft Graph SDK with the following structure for the chat members:

{ 
"@odata.type": "#microsoft.graph.aadUserConversationMember", 
"roles": ["owner"], 
"[email protected]": "https://graph.microsoft.com/v1.0/users('{user_principal_name}')" 
}  

The members array in the payload includes both the sender and the receiver of the chat message. So it is not clear to me why it is showing this BadRequest.

I have verified that I have all the necessary API permissions and authorization configured correctly.

Does anyone have insights into what might be causing this error?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,377 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 42,766 Reputation points
    2024-11-20T10:23:37.2266667+00:00

    Hi @Ruben

    If you are creating a one-on-one chat in a delegated context, the logged in user must be one of the members of the chat.

    POST https://graph.microsoft.com/v1.0/chats
    Content-Type: application/json
    {
      "chatType": "oneOnOne",
      "members": [
        {
          "@odata.type": "#microsoft.graph.aadUserConversationMember",
          "roles": ["owner"],
          "[email protected]": "https://graph.microsoft.com/v1.0/users('{currently logged in user id}')"
        },
        {
          "@odata.type": "#microsoft.graph.aadUserConversationMember",
          "roles": ["owner"],
          "[email protected]": "https://graph.microsoft.com/v1.0/users('xxxxxxxxxxxxxxxxxxxxxxxxxx')"
        }
      ]
    }
    

    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.


  2. Hitesh Pachipulusu - MSFT 3,235 Reputation points Microsoft Vendor
    2024-11-20T10:28:49.5166667+00:00

    Hello Ruben,

    Thank you for reaching out to Microsoft Support!

    The error message "The caller must be one of the members specified in request body" typically indicates that the user making the API call is not included in the members array of the chat creation request. Verify that the user who is making the API call (the caller) is indeed one of the members specified in the request body. Both the sender and the receiver should be included in the members array.

    If you do not want to provide signed-in user and want to provide two other users then you should use Application permissions.

    Hope this helps.

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


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.