Mattermost从curl命令

时间:2016-04-04 07:08:55

标签: curl mattermost

我在我的网站上设置了Mattermost创建频道github api。 请提供curl命令来创建新频道。

我在下面试过但是失败了

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

如果语法不正确,请告诉我?

1 个答案:

答案 0 :(得分:0)

看起来您错放了-H,而且您的数据周围缺少引号。

这对我在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

对于Mattermost 3.0+,这应该有效:

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

另请注意,由于Mattermost拒绝使用大写字母的名称,因此我降低了name JSON字段的值。