使用 curl 重命名 Github 上的标签
Rename a label on Github with curl
我正在尝试使用 REST API 重命名 Github 上的标签。我可以阅读标签
curl https://api.github.com/repos/adamschmideg/label-cleanup/labels/question
而且 returns 不错 json。
然而,当我尝试按照 Updating a Github issue label 上的文档更新它并执行此
curl \
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"
它 returns 一条消息 "Not found"。它 returns 与不存在的标签相同的消息。
我哪里错了?
这似乎是一个 public repository,这意味着任何人都可以看到它的标签。
但是,更新标签受到限制。您需要 authenticate,例如通过将 -u "username"
添加到您的基本身份验证请求中:
curl \
-u "adamschmideg" \ # <-- Right here
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"
如果您正在使用 two-factor 身份验证并且想要使用此处显示的基本身份验证,则需要 include a one-time code in a special X-GitHub-OTP
header as well。
GitHub 还支持在 headers 中或作为 URL 参数发送的 OAuth2 令牌,这不需要任何特殊步骤,如果您使用 2FA,建议这样做。
The reason 你得到的是 "Not found" 而不是像 "Please authenticate" 这样的东西
Requests that require authentication will return 404 Not Found
, instead of 403 Forbidden
, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.
我正在尝试使用 REST API 重命名 Github 上的标签。我可以阅读标签
curl https://api.github.com/repos/adamschmideg/label-cleanup/labels/question
而且 returns 不错 json。
然而,当我尝试按照 Updating a Github issue label 上的文档更新它并执行此
curl \
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"
它 returns 一条消息 "Not found"。它 returns 与不存在的标签相同的消息。
我哪里错了?
这似乎是一个 public repository,这意味着任何人都可以看到它的标签。
但是,更新标签受到限制。您需要 authenticate,例如通过将 -u "username"
添加到您的基本身份验证请求中:
curl \
-u "adamschmideg" \ # <-- Right here
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"
如果您正在使用 two-factor 身份验证并且想要使用此处显示的基本身份验证,则需要 include a one-time code in a special X-GitHub-OTP
header as well。
GitHub 还支持在 headers 中或作为 URL 参数发送的 OAuth2 令牌,这不需要任何特殊步骤,如果您使用 2FA,建议这样做。
The reason 你得到的是 "Not found" 而不是像 "Please authenticate" 这样的东西
Requests that require authentication will return
404 Not Found
, instead of403 Forbidden
, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.