Roy Sagi
Roy Sagi

Reputation: 1

Microsoft Teams API - Removing a member from channel returns [400] - BadRequest: Invalid id

Am trying to remove a user from a channel using the remove user from channel using this API call

Im getting 400 invalid id response on my user ID.

I've checked and my team, channel and user ID are all correct, and I'm trying to delete the user from a private channel as stated in the API and yet get the response.

This is the url passed: https://graph.microsoft.com/beta/teams/{team_aad_id}/channels/{channel_id}/members/{team_member_id}

The headers are the following:

{
   'Authorization': f'Bearer {access_token}',
   'Content-Type': 'application/json',
   'Accept': 'application/json'
}

And I have all the permissions stated in the API. Chat.ReadWrite.All and Group.ReadWrite.All

Any clue what should be done?

Upvotes: 0

Views: 919

Answers (1)

Jorge
Jorge

Reputation: 1186

Are you really using the team_member_id or are you using the user_azure_id?

If you get members from channel, Response is this:

"@odata.type": "#microsoft.graph.aadUserConversationMember",
        "id": "MHJKIOc2NjVjMGM5ZTc1NDg2YWFiOTgyNGVkNzasrtefiNmJAdGhyZWFkLnRhY3YyIyNlYzM5OGYzYy0zNDI4LTQwOGYtOGY3OC0wMTViZWZkYWQ5OA=",
        "roles": [],
        "displayName": "John Smith",
        "userId": "popopop-3428-408f-8f78-015befdad980",
        "email": "[email protected]"

Where userID is Azure User ID.

To remove a member from a channel you have to provide the Channel Member Id, which is the long id above

Upvotes: 1

Related Questions