GitHub API 尽管资源存在但返回 404
GitHub API returning 404 although resource exists
我正在尝试向 GitHub API 发送 POST 请求以提交对提交的评论。
根据 the documentation,所有需要的(URL 参数除外)是 body
.
我已将文档中的示例修改为以下内容:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/dchacke/test/commits/9b7413350932dd3f2906c0fdd26106c35c7ce450/comments \
-d '{"body":"test comment"}'
应该 post 对 this commit 进行测试评论。我知道提交、所有者和回购存在(这是我的回购,我可以看到 URL 下的提交),但我在提交 body 时收到 404 响应 body =35=] 请求:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-comment"
}
文档没有提到该端点需要身份验证。 404 听起来并不完全像身份验证问题,但以防万一 GitHub doesn't want to confirm the existence of repos/commits to unauthenticated users(尽管他们 做 让他们在他们的网站上看到这些东西.. .),我尝试在我的 CURL 请求中的附加 Authorization
header 中设置个人访问令牌。没有骰子。
我做错了什么?
身份验证毕竟是问题。我必须确保我使用了具有正确权限的令牌。本例需要public_repo
权限,可以设置here.
我正在尝试向 GitHub API 发送 POST 请求以提交对提交的评论。
根据 the documentation,所有需要的(URL 参数除外)是 body
.
我已将文档中的示例修改为以下内容:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/dchacke/test/commits/9b7413350932dd3f2906c0fdd26106c35c7ce450/comments \
-d '{"body":"test comment"}'
应该 post 对 this commit 进行测试评论。我知道提交、所有者和回购存在(这是我的回购,我可以看到 URL 下的提交),但我在提交 body 时收到 404 响应 body =35=] 请求:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-comment"
}
文档没有提到该端点需要身份验证。 404 听起来并不完全像身份验证问题,但以防万一 GitHub doesn't want to confirm the existence of repos/commits to unauthenticated users(尽管他们 做 让他们在他们的网站上看到这些东西.. .),我尝试在我的 CURL 请求中的附加 Authorization
header 中设置个人访问令牌。没有骰子。
我做错了什么?
身份验证毕竟是问题。我必须确保我使用了具有正确权限的令牌。本例需要public_repo
权限,可以设置here.