[SOLVED] I cannot post on mattermost through curl. Error 403



I cannot through curl command line in windows. I get the error:
403: You do not have the appropriate permissions

I can post with my user in the webb-app on this channel. I have tried several public channel that should work fine.

What am I doing wrong?

(Communicating with a Mattermost server version 4.2.0)

Steps to reproduce

curl -i -d “{“login_id”:“ulf.liljengren”,“password”:“pass”}” mattermost-server/api/v4/users/login

  • Copy the Token into next command

curl -i -H “Authorization: Bearer zuhmha33tjnfud1qh1pdk9so3o” -X POST -d “{“username”:“ulf.liljengren”, “channel_id”:“dacu3”,“message”:“Hello World.”}” mattermost-server/api/v4/posts

Expected behavior

Positive response with a post in the wanted channel.

Observed behavior

Console output:

C:\Git\actool\curl-7.56.1-win64-mingw\bin>curl -i -d “{“login_id”:“ulf.liljengren”,“password”:“pass”}” mattermost-server/api/v4/users/login
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 06 Dec 2017 09:24:44 GMT
Content-Type: application/json
Content-Length: 678
Connection: keep-alive
Set-Cookie: MMAUTHTOKEN=zuhmha33tjnfud1qh1pdk9so3o; Path=/; Expires=Fri, 05 Jan 2018 09:24:44 GMT; Max-Age=2592000; Http
Set-Cookie: MMUSERID=4smmi69fatn9bcpdktuie86xoh; Path=/; Expires=Fri, 05 Jan 2018 09:24:44 GMT; Max-Age=2592000
Token: zuhmha33tjnfud1qh1pdk9so3o
X-Request-Id: najzioh8jpgrxdik7ep11d5xeh

C:\Git\actool\curl-7.56.1-win64-mingw\bin>curl -i -H “Authorization: Bearer zuhmha33tjnfud1qh1pdk9so3o” -X POST -d “{“u
sername”:“ulf.liljengren”, “channel_id”:“dacu3”,“message”:“Hello World.”}” mattermost.server/api/v4/posts
HTTP/1.1 403 Forbidden
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 06 Dec 2017 09:25:34 GMT
Content-Type: application/json
Content-Length: 178
Connection: keep-alive
X-Request-Id: uqzgsawp4pbz8kby5tjuo8zhqh

{“id”:“api.context.permissions.app_error”,“message”:“You do not have the appropriate permissions”,“detailed_error”:"",“r


I have started to sniff my own TCP packages to diff how my mattermost web client can post a message and I don´t.

What do I miss in my post request compared to my mattermost web client?


I finally solved it!
Apparently “403: You do not have the appropriate permissions” does not only mean you do not have the rights, it also can mean that you cannot find the channel.
I simply misunderstood that the channel_id is not the name of the channel but the id of the channel. Not obvious the first time you try this.
So to get the channel_id you need find out the team_id by the GET team by name call.
Then you can post your message in Mattermost!


Hi @wolfnidh,

Pleased you have resolved your issue! Thanks for posting back the resolution!