0

Request

curl --location --request GET 'https://api.github.com/repos/gittestapi123/DataStructure/pulls/1/files' \

Above GET API returns 200 OK

Reponse

    {
        "sha": "9f4b6d8bfeaf44aaa69872286163784706d1b053",
        "filename": "testFile1",
        "status": "added",
        "additions": 1,
        "deletions": 0,
        "changes": 1,
        "blob_url": "https://github.com/gittestapi123/DataStructure/blob/266f3f884286b84f9d3b50a18e2a2534007a406b/testFile1",
        "raw_url": "https://github.com/gittestapi123/DataStructure/raw/266f3f884286b84f9d3b50a18e2a2534007a406b/testFile1",
        "contents_url": "https://api.github.com/repos/gittestapi123/DataStructure/contents/testFile1?ref=266f3f884286b84f9d3b50a18e2a2534007a406b",
        "patch": "@@ -0,0 +1 @@\n+This is a test file"
    }]

But for the same pull request If I submit GET request for GET /repos/{owner}/{repo}/pulls/{pull_number}/merge I get 404 (Even If I include valid authentication header)

Request

curl --location --request GET 'https://api.github.com/repos/gittestapi123/DataStructure/pulls/1/merge' \

Reponse

{
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/reference/pulls#check-if-a-pull-request-has-been-merged" }

I want to check if a pull request has been merged or not using the above API. Someone please please help on this?

Thanks in advance!

Thangakumar D
  • 714
  • 5
  • 12
  • 27

1 Answers1

0

You can see that it is not merged because you got a 404. In the documentation that you linked to:

Response if pull request has been merged

Status: 204 No Content

Not Found if pull request has not been merged

Status: 404 Not Found

(emphasis mine).

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • thanks @Edward. The request has a valid pull request. In my post, you can see I get 200 responses for /pulls/1/files GET requests. The pull request exists and it is mergeable – Thangakumar D Jan 25 '22 at 22:43
  • Yes, `/pulls/1/merge` responds differently than `/pulls/1/files`. For `.../merge` you get a 404 because it has not yet been merged. When you merge it you will get a 204. – Edward Thomson Jan 26 '22 at 01:21