Bitbucket REST API call to get list of repositories under a specific project


I’m trying to get a list of all repositories under the project “NEW” on my bitbucket server on prem
curl -D- -u sysadmin:password -X GET -H “Content-Type: application/json” https://localhost:PORT/rest/api/latest/repos?projectkey=NEW
where sysadmin has admin access to the repository NEW.

Problem is that it returns random repositories from other projects and a couple of recent repos from my project.

what am I doing wrong?


Try the “Get repositories for project” rest end-point instead:

curl --request GET \
  --url 'http://{baseurl}/rest/api/latest/projects/{projectKey}/repos' \
  --header 'Accept: application/json'

The API you are hitting (/repos) can take a “projectkey” parameter, but not a “projectKey” parameter (the documentation is confusing on this point). Also, the “projectkey” parameter is only available on that end-point from Bitbucket 8.0 or newer:

If you send a “projectKey” parameter you will receive all repositories subject to your page size, since “projectKey” is not a valid parameter and so it’s ignored. Whereas “projectkey” (all lowercase) is a valid parameter. Also, the “projectkey” parameter (all lowercase) will also be ignored and return you all repositories on Bitbucket 7.x or older.