0

我在我的网站上设置了 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

让我知道语法是否不正确?

4

1 回答 1

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

另请注意,我将nameJSON 字段的值小写,因为 Mattermost 拒绝使用大写的名称。

于 2016-05-31T12:55:56.597 回答