How do you delete a GitHub pull request requested review? - rest

How do you delete a GitHub pull request requested review? This is about deleting the request for review on a pull request, not the pull request itself. I can't find a way using the website.
I also tried using the REST API:
curl -i -X DELETE -u cherryblossom000 https://api.github.com/repos/<repo owner>/<repo name>/pulls/<pull number>/requested_reviewers -d '{"reviewers":["reviewer name"]}'
but I get this error:
{
"message": "Validation Failed",
"errors": [
"Could not add requested reviewers to pull request."
],
"documentation_url": "https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request"
}
The GraphQL API doesn't seem to have a mutation to delete a review request either.

I too had this problem and also got several "Validation failed" messages. So I figured it might be because I didn't have direct permissions on the repo.
After emailing Github developer support, they confirmed that you can delete (or dismiss) a review request, provided you have direct permissions on the repository.
In conclusion, your REST API approach is correct. You only get the "Validation failed" message if you do not have direct permissions on the repo.

Related

Retrieve artifacts from public repository using PAT

I am trying to download the latest artifact of a repository I don't own.
The API just gives me the following error:
{
"message": "You must have the actions scope to download artifacts.",
"documentation_url": "https://docs.github.com/rest/reference/actions#download-an-artifact"
}
The thing is, I don't see an "actions" box in when creating a personal access token. Here are the possible options, my token has access to "repo" and "workflow"
Is this on purpose, or have I missed something (another endpoint)?
As mentioned in the documentation:
Check headers to see what OAuth scopes you have, and what the API action accepts:
$ curl -H "Authorization: Bearer OAUTH-TOKEN" https://api.github.com/users/codertocat -I
HTTP/2 200
X-OAuth-Scopes: repo, user
X-Accepted-OAuth-Scopes: user
X-OAuth-Scopes lists the scopes your token has authorized.
X-Accepted-OAuth-Scopes lists the scopes that the action checks for.
So replace codertocat by the user of the repository you do not own, and check
X-Accepted-OAuth-Scopes to discover the expected scopes.
Compare them with X-OAuth-Scopes.

GitHub API returning 404 although resource exists

I'm trying to send a POST request to the GitHub API to submit a comment on a commit.
According to the documentation, all that's needed (other than the URL params) is the body.
I have modified the example from the docs to the following:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/dchacke/test/commits/9b7413350932dd3f2906c0fdd26106c35c7ce450/comments \
-d '{"body":"test comment"}'
That should post a test comment to this commit. I know the commit and the owner and repo exist (it's my repo and I can see the commit under that URL), and yet I'm getting a 404 with the following response body upon submitting that API request:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-comment"
}
The documentation makes no mention of authentication being required for that endpoint. A 404 doesn't exactly sound like an authentication problem, but just in case GitHub doesn't want to confirm the existence of repos/commits to unauthenticated users (though they do let them see those things on their website...), I tried setting a personal access token in an additional Authorization header in my CURL request. No dice.
What am I doing wrong?
Authentication was the issue after all. I had to make sure I used a token with the right privileges. In this case, it needed the public_repo privilege, which can be set up here.

Get Github Enterprise Stats using API

i am trying to fetch statistics of GitHub instance using the below command as per https://developer.github.com/enterprise/2.15/v3/enterprise-admin/admin_stats/
curl -u username:password https://<hostname>/api/v3/enterprise/stats/:all
However i am getting the below message. Please help me in fixing this issue
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/enterprise/2.14/v3"
}
Since the documentation states:
It is only available to authenticated site administrators.
Normal users will receive a 404 response if they try to access it.
Check first if you are declared as a site admin on your GitHub Enterprise server.
The issue got sorted by removing : (before all) in the api

No repository found for hub.topic - Scope issue?

I am trying to subscribe to changes in a particular repository but I'm getting a "No repository found for hub.topic".
Here's my request:
curl -u "user" -i https://api.github.com/hub -F "hub.mode=subscribe" -F "hub.topic=https://github.com/iOS-Goodies/iOS-Goodies/events/watch" -F "hub.callback=callback"
Given that this curl request follows Github's documentation guidelines and that it works for my own repositories, I assume this is a matter of scope.
Am I unable to subscribe to events on repositories I do not own?
Thanks
You have to be an administrator of the repository in order to perform that API request. The PubSubHubbub API follows the same permission rules as the Webhooks API: "The Repository Webhooks API allows repository admins to manage the post-receive hooks for a repository. Webhooks can be managed using the JSON HTTP API, or the PubSubHubbub API."

github api does not return my post-receive web hook

I have manually added a web hook to my repository, but when I query the repository using the API I get
{
"message": "Not Found"
}
what is wrong?
the url: https://api.github.com/repos/akonsu/kamyanov-art.com/hooks/
First, don't put the extra '/' at the end.
That will get you an message "Not Found" every time, authenticated or not.
Second, to add to Ivan's answer, you need to authenticate to access that information about a repo (public or private).
As mentioned in the "API Getting Started" page:
HTTP/1.1 404 Not Found
{
"message": "Not Found"
}
Oh noes! Where did it go?
If you’re a grizzled HTTP user, you might expect a 403 instead.
Since we don’t want to leak information about private repositories, the GitHub API returns a 404 in this case, as if to say “we can neither confirm nor deny the existence of this repository.”
That is why you see a "Not Found" here.
See issue 294
fwiw, I was scratching my head on this same issue trying to debug a hook, and the solution was to pass basic authentication on the request.
You are probably trying to access the API endpoint without authorising (in which case he API will return a 404 response and the JSON error you mentioned). Try passing your credentials with:
curl -v -u akonsu https://api.github.com/repos/akonsu/kamyanov-art.com/hooks