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

Rest API: member/user search?

Deli Soetiawan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 4, 2024

Is there any API available for searching/filter memberuser like when we add reviewer for pull request?

Screenshot 2024-03-04 at 15.00.54.png

 

I tried to use /workspaces/{{workspace_name}}/members but this only able to query by user.nickname and it must be exact (using =, cannot use ~)

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2024

Hello @Deli Soetiawan ,

thank you for reaching out to the Community!

Unfortuantely, the API used for the suggestions when you're adding a reviewer to a Pull Request is only internal, and not there's not currently a public endpoint for it.

As for the List users in a workspace endpoint, it indeed only supports exact matching with "=" (equal to) or "!=" (different than). One alternative that may work for you is to use a JSON processor, such as jq, to process the output of the API and filter by the string you are looking for. Following is an example of filtering the result of the API only for the users where nickname contains "Joe" : 

curl -X GET -u USERNAME:APP_PASSWORD 'https://api.bitbucket.org/2.0/workspaces/WORKSPACE/members?pagelen=100' | jq -r '.values[].user | select(.nickname | contains("Joe"))'

 The caveat of this workaround is that, since the max pagelen is 100, if you have more than 100 users in the workspace you are making the request to, you will have to iterate through the pages and apply that same filter to have the final result.

Another alternative, if your use case does not require the explicit usage of the API, is to export the entire workspace user list through Workspace Settings > User directory > Export.

This will generate a CSV file containing all the users of the workspace, which you can then search as you would do in a normal text file.

Hope that helps! Let me know in case you have any questions.

Thank you, @Deli Soetiawan !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events