如何使用GitHub API为问题添加标签?

时间:2018-05-07 14:54:43

标签: rest github

我正在尝试使用API​​为GitHub问题添加标签。检查API documentation后,我尝试了以下curl请求:

curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H  \
     "Accept: application/vnd.github.symmetra-preview+json" \
     -d @label.json https://api.github.com/repos/CHSUNSONG/star-platform/issues/11

label.json包含:

["submitted"]

但是,我收到了以下回复:

{
  "message": "Invalid request.\n\nFor 'links/1/schema', [\"submitted\"] is not an object.",
  "documentation_url": "https://developer.github.com/v3/issues/#edit-an-issue"
}

为什么这不起作用,我该如何解决?

1 个答案:

答案 0 :(得分:0)

您正在发布错误的网址。将/labels添加到最后:

curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H  \
     "Accept: application/vnd.github.symmetra-preview+json" \
     -d @label.json \
     https://api.github.com/repos/CHSUNSONG/star-platform/issues/11/labels