看起来您放错了位置-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
另请注意,我将name
JSON 字段的值小写,因为 Mattermost 拒绝使用大写的名称。