0
votes

I am working on posting a message in Microsoft Teams on behalf of an actual User using Microsoft Graph API but getting the below error:

User Id must match the api caller when called in delegated mode

The full error response is below:

{
    "error": {
        "code": "Unauthorized",
        "message": "User Id must match the api caller when called in delegated mode",
        "innerError": {
            "request-id": "87113028-5d7c-41e6-8a2b-918335117ec6",
            "date": "2020-06-05T09:08:13"
        }
    }
}

The Graph API that I have used is below one and the user id that I am specifying is not mine while it is another user's and got the above error when I have logged-in using my account.

https://graph.microsoft.com/beta/users/{user-id}/chats/{chat-id}/messages

Can anybody please suggest how to resolve the above issue. I am using global admin credentials to post a message on behalf of a user.

I think using the below link if we perform authentication and tries to get access on behalf of the user then it is possible to do the same. Can anybody please confirm?
https://docs.microsoft.com/en-us/graph/auth-v2-user

Thanks in advance.

1

1 Answers

0
votes

@Pravin, Your scenario is not very clear, i would suggest you to consider the Proactive messaging using Graph APIs. Please check the Proactive messaging documentations. In case your scenario is to send chant messages to user using Graph, please check Chat messages documentation.

The Link that you posted in the question is the authentication link, this can be used to read and write Microsoft resources on behalf of a user.