Issues

Issue #10237 resolved

API for merge pull request is not working / not consistent with the doc

Dong Xu
created an issue

The document here says that the API for merging a pull request is https://bitbucket.org/api/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pull_request_id}/merge.

However, this comment said the API is https://api.bitbucket.org/2.0/repositories/user/slug/pullrequests/id/accept.

Notice the last parts of the two different urls.

In REST API browser, /merge is not even there, but /accept will return the following error:

{
  "error":  {
    "message": "Resource not found",
    "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://confluence.atlassian.com/x/IYBGDQ"
  }
}

If you nevertheless try to use /merge API, you will get the following error:

{
  "error":  {
    "message": "name, email or commit message not provided",
    "detail": "  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py", line 208, in __call__\n    result = checked_meth(request, *args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py", line 195, in checked_meth\n    return meth(*args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/newrelic-2.18.1.15/newrelic/hooks/component_piston.py", line 33, in __call__\n    return self._nr_wrapped(*args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/bb/decorators.py", line 38, in wrap\n    return f(request, *a, **kwa)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/bb/decorators.py", line 375, in wrapped_function\n    return func(*args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/api/v10/decorators.py", line 78, in wrapped_function\n    return func(*args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/api/v10/decorators.py", line 206, in wrapper\n    return f(self, request, *args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/api/decorators.py", line 35, in wrapper\n    val = func(self, request, *args, **kwargs)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/pullrequests/api/v20/handlers.py", line 328, in create\n    return form.save()\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/pullrequests/forms.py", line 688, in save\n    self._merge()\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/pullrequests/forms.py", line 655, in _merge\n    closebranch=self.instance.close_anchor_branch)\n  File "/opt/python/domains/bitbucket.org/2013-11-26/bitbucket/../bitbucket/apps/compare/merge.py", line 61, in merge\n    destinationhead=destcset)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/git.py", line 1446, in merge\n    fastforward=fastforward)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 500, in pull\n    fastforward=fastforward)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 552, in fetchandmerge\n    localmarker=localmarker, remotemarker=remotemarker, force=force)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 581, in _fetchandmerge\n    (destcset, incomingcset), user, text, date)\n  File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 195, in commit\n    raise CommitError('name, email or commit message not provided')\n",
    "id": "f292da4c27624698a8ee8847e123019d"
  }
}

The doc says that only owner, repo_slug, and pull_request_id are required fields.

The inconsistency between the API and the doc is very frustrating. I am missing something very important?

Comments (3)

  1. Erik van Zijst staff

    That comment is outdated and wrong. I have updated it. The correct way to merge a PR is /merge (as per the links element in the pull request json document).

    Thanks for pointing this out!

  2. Joe DeCapo

    This issue doesn't appear to be resolved. I'm trying to use the pull request REST API to merge a pull request, and I'm getting the same error mentioned above, "name, email, or commit message not provided"

  3. Log in to comment