Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 2
Message 1 of 7

Creating PR results in 404 error?

Solved! Go to Solution.

I'd like to create Pull Requests via API (using PyGithub as implementation). For testing, I'm making a PR inside my repository from branch `mass-update-1` to `develop`.

 

Repository exists:

$ curl -u iarspider -i https://api.github.com/repos/iarspider/spack 

HTTP/1.1 200 OK

(...)

 

Branches exist:

$ curl -u iarspider -i https://api.github.com/repos/iarspider/spack/branches/mass-update-1
HTTP/1.1 200 OK

(...)


$ curl -u iarspider -i https://api.github.com/repos/iarspider/spack/branches/develop
HTTP/1.1 200 OK

(...)

 

But creating a PR results in 404:

$ curl -X POST -d '{"title": "Add extra version of expat", "body": "Split from #14570", "base": "develop", "head": "mass-update-1"}' -H "Content-Type: application/json" -u iarspider -i https://api.github.com/repos/iarspider/spack/pulls


HTTP/1.1 404 Not Found
Date: Fri, 14 Feb 2020 10:43:47 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 116
Server: GitHub.com
Status: 404 Not Found
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4951
X-RateLimit-Reset: 1581677662
X-OAuth-Scopes:
X-Accepted-OAuth-Scopes:
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding, Accept, X-Requested-With
X-GitHub-Request-Id: A4FA:5C8F:A25DE:C513C:5E4679E3

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

 

6 Replies
Highlighted
Commander Lvl 1
Message 2 of 7

Re: Creating PR results in 404 error?

Hey, the first step I would try would be to swap the order of "base" and "head" to match up with the API's example directly. Let me know if that does not work. 

Highlighted
Ground Controller Lvl 2
Message 3 of 7

Re: Creating PR results in 404 error?

Nope, same 404 error:

$ curl -X POST -d '{"title": "Add extra version of expat", "body": "Split from #14570", "head": "mass-update-1", "base": "develop"}' -H "Content-Type: application/json" -u iarspider -i https://api.github.com/repos/iarspider/spack/pulls

HTTP/1.1 404 Not Found
Date: Fri, 14 Feb 2020 14:37:27 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 116
Server: GitHub.com
Status: 404 Not Found
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
X-RateLimit-Reset: 1581694647
X-OAuth-Scopes: 
X-Accepted-OAuth-Scopes: 
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding, Accept, X-Requested-With
X-GitHub-Request-Id: EBEC:2D3DF:64A6B7:7A2C41:5E46B0A7

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/pulls/#create-a-pull-request"
}
Commander Lvl 1
Message 4 of 7

Re: Creating PR results in 404 error?

I think the issue may be that you aren't authenticated. I am pretty sure you need to use a GitHub Personal Access token in order to do what you're trying to do (since theoretically right now all you are providing is a user name, which anyone who sees's your public repo could access and subsequently make the same API request as you). The 404 is likely saying "hey, someone is trying to access this command without telling us who they really are so we don't want to get involved in that. Let's tell them as little as possible (for security reasons) and return a 404". 

 

https://developer.github.com/v3/guides/getting-started/#authentication

Highlighted
Ground Controller Lvl 2
Message 5 of 7

Re: Creating PR results in 404 error?

I am using personal token, I'm just not showing it.

Highlighted
Solution
Commander Lvl 1
Message 6 of 7

Re: Creating PR results in 404 error?

It is possible your Personal Access Token does not have the correct permissions set to write to the repo. I suggest checking your current permissions.

Highlighted
Ground Controller Lvl 2
Message 7 of 7

Re: Creating PR results in 404 error?

Yup, had to add "access public repositories" to the token. Wish it was documented somewhere :)