How to create Github Pull Request using curl?

我们两清 提交于 2019-12-06 02:31:23

问题


I am trying to create a Github Pull Request using curl (in a bash script) and authenticating using token.

I am getting response for curl -u my-user:token https://api.github.com/user. I am getting response for curl https://api.github.com/repos/repo-owner/repo-name/pulls

But when I try to create a pull request using the following curl command, I am getting errors:

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"
}

How to fix? What I am doing wrong?

I am not interested in creating pull request using hub its working fine with hub. I want to know how to use curl and do that. Thank you in advance!


回答1:


If you're still struggling with this, make sure the token you're using has the "public_repos" permission.




回答2:


This (create a Pull Request) is supposed to be a POST.

POST /repos/:owner/:repo/pulls

See this curl tutorial for GitHub API:

curl --user "..." -X POST


来源:https://stackoverflow.com/questions/47467039/how-to-create-github-pull-request-using-curl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!