Closing a pull request through github API

Viewed 3302

As per the design requirements of our application, we used to delete the merge requests in Gitlab using gitlab API. Now we are migrating to Github and I am looking for a similar API call which closes the pull requests on Github.

I read through the documentation here, but it doesn't answer my question.

I would be glad if someone could help me with it.

1 Answers

If you read the API documentation whose link you pasted above, it seems that there is an update endpoint which can be used to assign the state of a pull request:

PATCH /repos/:owner/:repo/pulls/:number

{
    "title": "new title",
    "body": "updated body",
    "state": "closed",
    "base": "master"
}

The state key inside the JSON can be either open or closed.

Related