Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get Admins of a particular project in Bitbucket using rest api

Mansi Patel April 19, 2018

Hi,

I tried to use following API ******/REST/API/1.0/PROJECTS/ACSC/PERMISSIONS/USERS?FILTER=PROJECT_ADMIN

with headers

Content-type:applicaiton/json

Accept:Application/json

 

But I am getting list of admins of that project. I do understand that FILTER value could be different but in rest api doc, there is no request example.

https://docs.atlassian.com/bitbucket-server/rest/5.1.0/bitbucket-rest.html#idm45588158637696

 

Thanks,

Mansi

1 answer

1 accepted

1 vote
Answer accepted
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2018

Hi @Mansi Patel,

 

The filter is not based on the role of the user, instead it is based on the username.

 

Let's work through an example here.

 

Let's say that we have 3 users and a project called project1:

- charlie (with Admin permissions on project1)

- user1 (with Admin permissions on project1)

- user2 (with Write - but not Admin - permissions on project1)

 

I then use the rest endpoint to retrieve the details of the users.

 

Example one - no filter applied

/rest/api/1.0/projects/project1/permissions/users

This will be the response:

{"size":3,"limit":25,"isLastPage":true,"values":[
{"user":{"name":"charlie",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user1",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user2",...,"permission":"PROJECT_WRITE"}],...

 

Example two - filtering for user as username

/rest/api/1.0/projects/project1/permissions/users?filter=user

This will be the response:

{"size":2,"limit":25,"isLastPage":true,"values":[
{"user":{"name":"user1",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user2",...,"permission":"PROJECT_WRITE"}],...

The charlie user is not listed because it does not match contain the "user" string.

Example three - filtering for r as username

/rest/api/1.0/projects/project1/permissions/users?filter=r

This will be the response:

{"size":3,"limit":25,"isLastPage":true,"values":[
{"user":{"name":"charlie",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user1",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user2",...,"permission":"PROJECT_WRITE"}],...

All users are returned because they all contain "r" in their username.

 

Note: the response in the examples is truncated and the less relevant details have been replaces with "..."

 

 

Does this help? If you could share what you are trying to achieve, we may be able to provide a more specific reply.

 

Cheers,

Caterina - Atlassian

Mansi Patel April 27, 2018

Hi Caterina,

 

Thanks for details response, I can work with following Api.

/rest/api/1.0/projects/project1/permissions/users

This will be the response:

{"size":3,"limit":25,"isLastPage":true,"values":[
{"user":{"name":"charlie",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user1",...,"permission":"PROJECT_ADMIN"},
{"user":{"name":"user2",...,"permission":"PROJECT_WRITE"}],...

 Also, as I understand there is no specifically API to filter based on project permissions. In my opinion, it makes senses to have API to filter based on Permissions so that we don't need to filter through response.

 

Thanks,

Mansi

Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2018

Hi @Mansi Patel,

Great! It is correct that there is no specific API to filter on project permissions.

Have a look at this article as well (if you did not already):

How to report on permissions by querying the database

 

Cheers,

Caterina - Atlassian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events