Forums

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

User Searches Using the REST API and "query" parameter

Kevin Chen October 26, 2018

Given the GDP changes that are coming for cloud (https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/), we are trying to use the v2 api to search for users using the "query" parameter (https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-api-2-user-search-get)

 

If I want to search for a known user with a known "displayName" of "Bob", how should the URL be formed?  I've tried the following but only get HTTP 200 with no results (Insomnia client will encode reserved characters after the first "="):

https://<our cloud instance>/rest/api/2/user/search?query=displayName=Bob

https://<our cloud instance>/rest/api/2/user/search?query=displayName="Bob"

 

1 answer

1 accepted

1 vote
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2018

I think understand what you're trying to do here, but I don't believe there is a way to search only the displayName value on accounts at this time.  The current rest documentation doesn't make this explicitly clear though, however when searching for user accounts via rest, using either the query or username parameters, the following attributes always get searched in the search process:

  • username
  • displayname
  • email address

I can see why this would be potentially problematic when searching for a specific user.  But at the very least you should be able to change your URL to be

https://<our cloud instance>/rest/api/2/user/search?query=Bob

to get back all the accounts that any of those attributes that start with that string.

Kevin Chen October 30, 2018

Thanks.  You might want to update the documentation with an example.  This was extremely confusing / frustrating.

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2018

Fair point.  I will create a documentation update request to help make this more clear.  Thanks for reporting it.

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 7, 2018

Hello @Kevin Chen and @André Mens

Just FYI, the documentation for the REST API endpoints needs indeed to be updated (especially the examples, some of them are missing the parameter/s) and some time ago I started creating the  below documentation requests:

I believe the first one is addressing what discussed in this thread.

 

Cheers,
Dario

Like • Dip Pramanik likes this
Anand Elumalai February 19, 2019 edited

Hello @Andy Heinzer 

      Shall we use the get user API without username, query parameters. Shall we call the API just like https://<our cloud instance>/rest/api/2/user/search?query=startAt=1&maxResults=1000 . This will return the first 1000 users?

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2019

Hi @Anand Elumalai 

Have you review the 3 documentation requests I liked above? I believe the answer to your  question is in there:

https://HOSTNAME/rest/api/latest/user/search?query=something@example.com

 

Otherwise, please provide a bit more context on what you are trying to achieve, I may have misunderstood the question :) 

Suggest an answer

Log in or Sign up to answer