Bitbucket Server REST API for merging Pull Request fails


アトラシアン コミュニティをご利用ください。


プラットフォームについて: Server と Data Center のみ - この記事は、サーバーおよびデータセンター プラットフォームのアトラシアン製品にのみ適用されます。


When merging a Pull Request using the REST API, a similar JSON response is returned by the server:

    "errors": [
            "context": null,
            "message": "You are attempting to modify a pull request based on out-of-date information.",
            "exceptionName": "com.atlassian.stash.pull.PullRequestOutOfDateException",
            "currentVersion": 0,
            "expectedVersion": -1,
            "pullRequest": {
                "id": 1,
                "version": 0,
                "title": "Test",
                "description": "asdf",
                "state": "OPEN",



  • From the JSON above, the version value-pair (line 11) of the sample Pull Request is 0. That is a mismatch with the version parameter you're sending on your REST call.


According to the Bitbucket Server REST API documentation, the default value for version is -1. You need to specify the right value during your REST call.


  • You can use the version informed by the JSON sample above. In that case, it is 0.
  • If you are unable to identify the version, you can run the following command to find out the version of a Pull Request:
    • If for some reason you can't see the version of the Pull Request above, could you please run the following curl call and get your Pull Request version?

      curl -H "Content-Type:application/json" -H "Accept:application/json" --user admin:admin -X GET http://<Your_Stash_URL>/rest/api/1.0/projects/<PROJECT_ID>/repos/<REPO_ID>/pull-requests/<PR_ID>/
  • To fix the reported error, please run the following curl command, passing the version parameter as part of the URL:

    curl -H "Content-Type:application/json" -H "Accept:application/json" --user admin:admin -X POST http://<Your_Stash_URL>//rest/api/1.0/projects/<PROJECT_ID>/repos/<REPO_ID>/pull-requests/<PR_ID>/merge?version=0

If you are running your own script (i.e. Python or any other language), please run a test with the curl calls above. We've seen errors in scripts causing similar issues and curl is always a spot on way to solve those.

最終更新日: 2016 年 2 月 26 日


Powered by Confluence and Scroll Viewport.