Reputation: 77
I'm trying to make a pull request to GitHub using it's REST API directly, using this documentation:
https://developer.github.com/v3/pulls/#create-a-pull-request
I have created a public repo, and I try the operation of the retrieve of the pull requests by the API, and works fine. But when I try to create a pull request using this operation:
POST /repos/:owner/:repo/pulls
and this body:
{
"title": "Amazing new feature",
"body": "Please pull this in!",
"head": "theOwner:new-branch",
"base": "master"
}
then I receive this message from the response:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/pulls/#create-a-pull-request"
}
The full url that I make the request is:
https://api.github.com/repos/alvarocallero/node-test/pulls
Is right the body of the request that I'm using? May be the value of "head" is not the correct one.
Upvotes: 4
Views: 17755
Reputation: 77
After using Basic Authentication as @Yug Sing suggest, then I can finally make the PR via API: my problem was that on the creation on the token for the basic auth, instead of using userName and accessToken, I used userName and my password of git, so the authentication fails
Upvotes: 1
Reputation: 3430
I created a feature
branch in the same repository against whom I wanted to create a Pull request. After that I invoked the api POST /repos/:owner/:repo/pulls
as mentioned in the question with the following body:
{
"title": "Amazing new feature",
"body": "Please pull this in!",
"head": "feature",
"base": "master"
}
As you can see since my feature
branch is in the same repo as the master against whom I am creating a Pull request I just mentioned it's name in the head
.
After this I also ensured that I pass Authorization
(Basic Auth ) and when I invoked the API the Pull request was created in the github.
Then I tried invoking the above API without passing the Authorization header and I got 404
. Therefore I think you need to correct head
value in the body as you mentioned in the comment that your branch is in the same repo as that of master against whom you are creating a Pull request. And make sure to pass the Authorization header
Upvotes: 2