如何使用curl创建Github Pull Request?

9
我正在尝试使用curl(在bash脚本中)创建Github拉取请求并使用令牌进行身份验证。
我可以通过curl -u 我的用户名:令牌 https://api.github.com/user获取响应。我可以通过curl https://api.github.com/repos/拥有者用户名/仓库名称/pulls获取响应。
但是,当我尝试使用以下curl命令创建拉取请求时,出现错误:
curl -d '{"title":"testPR","base":"master", "head":"user-repo:master"}' https://api.github.com/repos/repo-owner/repo-name/pulls

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/pulls/#create-a-pull-request"
}

如何修复?我做错了什么?

我不想使用hub来创建拉取请求,使用hub可以正常工作。 我想知道如何使用curl来实现。谢谢您提前!

2个回答

7
如果你仍然遇到困难,请确保你正在使用的令牌具有 "public_repos" 权限。

1
谢谢@thislooksfun,显然这是一个权限问题。 - Gaurav N

4

是的,我已经检查过了。它还说-d表示该请求是POST请求。即使这样,它仍然无法工作。curl -u“用户名” -X POST -d '{"title":"testPR","base":"master", "head":"user-repo:master"}' https://api.github.com/repos/repo-owner/repo-name/pulls - Gaurav N
2
@GauravN 您的curl命令没有包括 -u: 您是否使用了您的令牌? - VonC
FYI:GitHub API链接已经失效。虽然这个链接可能不正确,但它看起来很接近:https://gist.github.com/btoone/2288960 - undefined
@RandallBecker 感谢您的反馈。我已经相应地编辑了答案。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接