9

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!

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @thislooksfun, apparently it was a permissions issue.
4

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

3 Comments

Yes, I checked it. It also says -d implies that that request is POST. Even with that its not working. curl -u "user-name" -X POST -d '{"title":"testPR","base":"master", "head":"user-repo:master"}' https://api.github.com/repos/repo-owner/repo-name/pulls
@GauravN Your curl command does not include -u: are you unsing your token?
FYI: The GitHub API link does not work any longer. While this one might not be correct, it seems close: gist.github.com/btoone/2288960

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.