Get default reviewers API in Bitbucket Datacenter fails with NoSuchBranchException

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

The API to get default reviewers in Bitbucket Datacenter fails with NoSuchBranchException. 

(Auto-migrated image: description temporarily unavailable)

Environment

The solution has been validated in Bitbucket Datacenter 8.9.5 but may be applicable to other Bitbucket 8.x versions

Diagnosis

The below API returns NoSuchBranchException, though the branch exists in the Bitbucket repository.

1 2 3 4 5 6 7 8 9 10 curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${sourceRefId}&targetRefId=${targetRefId}' --header 'Accept: application/json' Parameters: sourceRepoId = The ID of the repository in which the source ref exists targetRepoId = The ID of the repository in which the target ref exists sourceRefId = The ID of the source ref targetRefId = The ID of the target ref For example,  curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/PRJ/repos/repo1/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${source-commit-hash}&targetRefId=${target-commit-hash}' --header 'Accept: application/json'

Cause

Prior to Bitbucket 8.0, it was possible to pass a commit hash to sourceRefId and targetRefID parameters in the API to review the results. Starting with Bitbucket 8.x, a commit hash is not considered as a valid RefID. A valid RefID would be a branch or a tag name.

Solution

A valid RefID such as a branch name or tag name is to be passed to sourceRefID and targetRefID parameter values to run the API successfully and retrieve default reviewers.

1 curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/PRJ/repos/repo1/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${source-branchname}&targetRefId=${target-branchname}' --header 'Accept: application/json'

Updated on March 12, 2025

Still need help?

The Atlassian Community is here for you.