Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve all repositories of a team from bitbucket cloud api

kswati March 19, 2019

I am in admin group of my team, but when I am trying to get list of all repositories using this api:

curl --user user:password https://api.bitbucket.org/2.0/repositories/team?q='project.key="JG"' | jq '.values[].name' | tr -d '"'

It is not getting all list of repositories in this project , how to get list of all repositories in a projectcreated by any team member?

 

1 answer

0 votes
Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2019

Hi @kswati ,

The endpoint you are calling (/2.0/repositories/team) seems to be unavailable, at least based on https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories

You could call /2.0/teams/{username}/projects/{project_key} as described in https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/projects/%7Bproject_key%7D

teams
  {username}
    projects
      {project_key}

Kind regards,
Rafael

kswati March 20, 2019

The api command I have mentioned above are getting list of some repo in one project not all repositories even with admin user dont know why, but the one you are mentioning is not fetching or retrieving any list of repositories in a project.

Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2019

Hi @kswati ,

Sorry for the misunderstanding. The REST API endpoint you are calling, where it says "team", is the actual {username} given to the team, so yes, that endpoint can be used.

The endpoint you are calling should return a paginated list of all repositories owned by the specified account or UUID, and you could get the result based on the authenticated user's role.

E.g. with ?role=contributor, only those repositories that the authenticated user has write access to are returned (this includes any repo the user is an admin on, as that implies write access), and the role accepts any of the values below:

  • member: returns repositories to which the user has explicit read access
  • contributor: returns repositories to which the user has explicit write access
  • admin: returns repositories to which the user has explicit administrator access
  • owner: returns all repositories owned by the current user

Since you mentioned you are unable to view all repositories, how many results are you getting when consuming the REST API endpoint? How many pages are in the response?

Kind regards,
Rafael

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events