0

I am trying to perform a few operations on GitHub APIs.. and I am looking to delete the pull requests with the pull id and with the title, but I cannot find anything...

to get pull requests I used the following...

pull_req=$(curl -s -u $username:$password https://api.github.com/repos/$username/$repository_name/pulls?state=all | jq -r '.[] | "\(.title) '--'  \(.number)"')
echo $pull_req

like as follows:

the following are the pull requests with their id:
adding file333 --  3
Branch2 --  2
Create file123 --  1

the above shows the pull requests for both opened and closed along with the pull request-id...

I want to delete that pull request, using the API

I tried the update from the GitHub docs, but I did not find any changes...

https://docs.github.com/en/rest/reference/pulls#update-a-pull-request

and what does the update exactly do?

does this give a proper deletion?

any other methods using API to delete the pull requests would be very helpful

Thanks in advance...

ganesh tirumani
  • 35
  • 1
  • 10
  • You cannot really *delete* a pull request yourself. However, you can *close* a pull request. Deleting is not possible in the UI and not over the API. The following question deals with this: [Delete a closed pull request from GitHub](https://stackoverflow.com/questions/18318097/delete-a-closed-pull-request-from-github) – Matt Jan 18 '22 at 12:50
  • Thank you very much @Matt, but is any API to close the pull requests? I searched a few, I found one: https://stackoverflow.com/questions/47343739/closing-a-pull-request-through-github-api ... using 'update', can I close the pr? how can I close using an api? – ganesh tirumani Jan 18 '22 at 14:34
  • You can most likely send a *PATCH* request with the JSON-payload `{ "state": "closed" }` to `/repos/:owner/:repo/pulls/:number` as described in the answer to the question you linked to. – Matt Jan 18 '22 at 16:16

0 Answers0