0

I have setup Mattermost create channel github api on my website. Please provide curl command to create the a new channel.

I have tried below but it fails

curl -H "Content-Type: application/json" 'Authorization:Bearer (removed)' -X POST -d -H {"display_name":"testviaCurl","name":"testViaCurl","team_id":"(removed)","purpose":"","type":"O"} http://zzz.zzz.co/api/v1/channels/create

Let me know if the syntax is incorrect?

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
user5337216
  • 105
  • 2
  • 13
  • Please do not ask others to do the work for you. Instead explain your problem, what you have tried so far and detailed error descriptions. Also, never publicly post access tokens etc. Cleanup your examples from tokens, passwords etc. – Marian Theisen Apr 04 '16 at 08:00
  • Please see the curl command which I had already posted along with my query and see if you can help or tell me what is wrong in there. – user5337216 Apr 04 '16 at 11:43

1 Answers1

0

It looks like you have a misplaced -H and you're missing quotes around your data.

This worked for me on Mattermost 2.2:

curl -H "Content-Type: application/json" -H "Authorization: Bearer yourtokenhere" -X POST -d '{"display_name":"testviaCurl","name":"testviacurl","team_id":"yourteamid","purpose":"","type":"O"}' http://yourmattermostinstance.com/api/v1/channels/create

For Mattermost 3.0+, this should work:

curl -H "Content-Type: application/json" -H "Authorization: Bearer yourtokenhere" -X POST -d '{"display_name":"testviaCurl","name":"testviacurl","team_id":"yourteamid","purpose":"","type":"O"}' http://yourmattermostinstance.com/api/v3/teams/<yourteamid>/channels/create

Also note that I lower cased the value for the name JSON field since Mattermost rejects names with uppercases.