Response: No team member found for that user ID and team ID.
The channel type is “G” (Group channel).
I’m sure that the user_id sent in the payload is not in that channel and is inside the team that the other users inside the channel are, and yet I’m receiving this error message:
What is wrong with this request? and what is the proper way to use this endpoint?
That error is unclear in this case, but users cannot be added to group message channels since they work similar to direct message channels. You can instead either create a private channel for those users, which is easier if you’ll want to add/remove users later on, or create a new group channel with all of the users you want
The problem is that I want to add a user to a channel using the “Add user to channel” endpoint, but (at least from your comment) I think that what is wrong with my approach is that I’m using an incorrect channel type to begin with.
So, if I understand well, the thing is that I need to user “private channels” to make it possible to add users with that endpoint right?
If that is the case, can you give me an example of the correct usage of the “Add user to Channel” endpoint?
Yes, that’s right. The request you were using above is correct, except the channel_id part of http://<server>/api/v4/channels/<channel_id>/members must be for a channel with type “O” (a public channel) or “P” (a private channel). If you don’t already have one of those channels to use, you can use this API route to create one with the correct type.