Forums

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

JIRA API - Find users query behavior

KORTX Support February 1, 2022

I'm trying to understand the behavior of the following endpoint -

GET /rest/api/3/user/search

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get

 

The documentation describes the query param as following -

query

string

A query string that is matched against user attributes ( displayName, and emailAddress) to find relevant users. The string can match the prefix of the attribute's value. For example, query=john matches a user with a displayName of John Smith and a user with an emailAddress of johnson@example.com. Required, unless accountId or property is specified.

 

Can this endpoint be used to reliably find a user by email even though the email address may or may not be included in the response?

For example, GET /rest/api/3/user/search?query=user@domain.com

 

I was worried we may have an issue if a user with the displayName 'user@gmail.com' exists.

I tested this scenario by posting a user with this displayName and the user was not included when I queried using GET /rest/api/3/user/search?query=user@domain.com.

 

Is the behavior of the query to only search by email if string is in an email format.

For example, GET /rest/api/3/user/search?query=domain.com would include the user.

 

Let me know any further clarification is needed.

 

1 answer

1 vote
Pramodh M
Community Champion
February 1, 2022

Hi @KORTX Support 

Searching with an email address is possible

It has to match the exact email address as far as I know

The user is returned if it exactly matches the First name or email address

If multiple users have the same first name, all the matching first name users are returned!!

Thanks,
Pramodh

KORTX Support February 2, 2022

Thanks @Pramodh M

 

I'm assuming that by first name, you mean displayName. Jira users have no concept of a firstName.

 

The interesting scenario I noticed though was this -

With a user whose displayName ="tmp@domain.com" or any user who's displayName is the format of an email, querying the search endpoint returns nothing.

GET /rest/api/3/user/search?query=tmp@domain.com returns and empty array.

 

I don't know the source code but it appears that if the query is in an email format, the search endpoint won't attempt to match a displayName and only attempts to match by email. 

 

It's an edge case, but I'm just looking to confirm the true behavior of the query param.

Pramodh M
Community Champion
February 2, 2022

@KORTX Support 

Why is the displayName email address?

KORTX Support February 2, 2022

@Pramodh M 

 

It's a valid value for that field.

Akram Rabie
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!
February 22, 2023

I hope this answer would help since it's been a long time since the last answer but anyways, this is what I did to get the exact user for the specific email address.

You need to pass the query and also specify the `emailAddress` property like this:

 

/user/search?emailAddress=user@whatever.com&query=user@whatever.com

the weird part is that if you do not pass `query=user@whatever.com` (or any other value that matches with a part of your user name or email), you'll get 400 error because the `query` is mandatory!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events