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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there ,
Not sure if this was available back then, but the current version of API does have option to find user based on permission.
/rest/api/latest/projects/<Project_key>/permissions/search?permission=<Project_role>
/rest/api/latest/projects/<Project_key>/permissions/search?permission=PROJECT_ADMIN
Cheers,
Nihar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.