Mattermost, Inc.

API Posts return "You do not have the appropriate permissions?"

I’m working on a Python wrapper for the Mattermost API and I’ve run up against a bit of a wall.

I am able to authenticate using group name, email, and password.

I am able to get a list of channels or posts.

I am not able to do anything so far that requires a POST (like joining or posting to a channel) and I’m having a hard time finding what I’m missing in the client.go and post.go source code.

I’m including my authentication token in the request header and that seems to be working because if I remove it I get a completely different error.

For example, posting a message to a channel (some values redacted):

POST /api/v1/channels/{channel_id}/create HTTP/1.1
Host: chat.{server}.com
Authorization: BEARER {my_user_token}
Content-Type: application/json
Cache-Control: no-cache

{Message: "Test"}

Returns:

{
  "message": "You do not have the appropriate permissions",
  "detailed_error": "userId={my_user_id}",
  "request_id": "#########################",
  "status_code": 403,
  "is_oauth": false
}

Am I missing or misunderstanding something?

Replying to myself because of course I figured it out almost as soon as I finally post for help :wink:

It looks like my problem was that channel_id is a required parameter for the post JSON.

It seems redundant to require that since it can be determined from the endpoint URL though, no?