What is the best waty to get list of projects and repositories and type of permission that given user have to Bitbucket server

I would like to know your suggestions on how to achieve it :slight_smile: Thanks

Hi,
This question is regarding bitbucket server right? A bit confused by the Jira-server tag (Jira has it’s own archiving API) Would be nice to tag it as bitbucket-development if that’s the case… :slight_smile:

Hi,

You can use the REST API to achieve getting paged list of projects and subsequently repositories within those projects.

With regards to the type of permission a user has, you might need to elaborate a little more. At a basic level you can get a list of users that have been granted at least one global permission by making a request to $BASE_URL/rest/api/1.0/admin/permissions/users?[filter={string}. This will return a page of users that have been granted at least one global permission and will list their highest granted permission. This won’t however, tell you about any users that do not have global permissions and instead get their permissions from groups. For that you can make a request to $BASE_URL/rest/api/1.0/admin/users/more-members?context={userSlug} which will give you a list of groups the user is a member of, and you can then check whether what global permissions that group has using $BASE_URL/rest/api/1.0/admin/permissions/groups?filter={groupSlug}.

Perhaps you could share what it is you’re trying to achieve, i.e. why do you need to know the permissions? Perhaps a good use case example for what you’re trying to do will help us better answer this question for you :slight_smile:.

Regards,

John van der Loo
Developer, Bitbucket Server