Can't find a way to get the private messages from the API

Hi there,

I’m currently working on a Weechat plugin to connect to Mattermost through the Python driver.

Unfortunately, I can’t find a way to get connected user private message through the v4 API.

Get channels for user returns public channels in the team and direct messages but not private channels.

I can access the private channels by its names through Get a channel by name and team name but can’t find a way to get these name before.

Am I missing something or is it not possible with the API ?

Hello, @j0ack

I was able to pull the direct messages between 2 users based on the channel ID (direct message) that I pulled from the database. For example:

curl --location --request GET "https://<url>/api/v4/channels/<channel_id>/posts" --header "Authorization: Bearer <access_token>" --header "Content-Type: application/json" | python -m json.tool

May I know if you are looking at this or posts from specific users in a direct message channel?

Hello @ahmaddanial,

Thanks for your answer. I realized my question is not clear enough. My user is in a team that have public and private channels. I did not find a way to get those private channels from the API.

When I get all the channels for the connected user, I can only get the team public channels and the private messages between users but not the private channels for the team even if my user is a participant.

I can get posts from these channels if I already know the channel’s name or its id. But I can not find a way to do it programmatically since I have no trace of it when I get all the user’s channels.