Adding Branch Protection Rules through endpoint API #24762
-
I am trying to add a Pull request review protection rule to one of the repositories I am working on, and using the following API call to add it:
I keep getting this error message. When I try to check the repository branch, I get a 404 for found error message: https://api.github.com/repos/seanmalloy-crest/test_environment/branches/main/protection.
And I also tried this command and got this error message instead:
I would really appreciate the help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Looking at other posts, I am getting the same issue asked about here:
We ran into a problem that is quite confusing - we have a user trying to access the endpoint: /repos/:owner/:repo/branches/:branch/protection via a curl call to the API. He consistently receives a “404 Not found #get-required-status-checks-of-protected-branch” type error. His access token is valid and works across other endpoints in the same repo, so it’s not a credentials issue, for example. He *can* access: /repos/:owner/:repo/branches/:branch and it even lists the ‘protection’ url it cl… I personally do not have the required access though I am using a Github Token that should have admin permission to that repository. |
Beta Was this translation helpful? Give feedback.
-
Hey @seanmalloy-crest how are you going, aside from these API troubles? Well, I hope! You mentioned:
But in your example curl, there was no token being applied to your calls, that I could see. At least, not from your screenshot above. Our REST Authentication docs are here: docs.github.comGetting started with the REST API - GitHub Docs//docs.github.com/en/rest/guides/getting-started-with-the-rest-api Because a 404 not found could easily mean permissions issues and if you aren’t passing a token with valid permission, would explain what you see. Let us know if you continue to have trouble after properly authenticating your calls! 🙇 |
Beta Was this translation helpful? Give feedback.
-
Thanks, that seemed to help a lot! Here is the final curl call I made, in case if anyone else has a similar issue:
|
Beta Was this translation helpful? Give feedback.
Hey @seanmalloy-crest how are you going, aside from these API troubles? Well, I hope!
You mentioned:
But in your example curl, there was no token being applied to your calls, that I could see. At least, not from your screenshot above. Our REST Authentication docs are here:
docs.github.com
Getting started with the REST API - GitHub Docs
//docs.github.com/en/rest/guides/getting-started-with-the-rest-api
Because a 404 not found could easily mean permissions issues and if you aren’t passing a token with valid permission, would explain what you see.
Let us know if you continue to have trouble after properly …