Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Github Pull Request using curl?

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!

like image 512
Gaurav N Avatar asked Nov 24 '17 05:11

Gaurav N


People also ask

How do I create a pull request on my repository?

Go to your repository on GitHub and you'll see a button “Compare & pull request” and click it. Please provide necessary details on what you've done (You can reference issues using “#”). Now submit the pull request. Congratulations!

What is curl in GitHub?

curl Public. A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP.


2 Answers

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

like image 107
thislooksfun Avatar answered Oct 02 '22 19:10

thislooksfun


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
like image 29
VonC Avatar answered Oct 02 '22 19:10

VonC