I'm trying to understand the behavior of the following endpoint -
GET /rest/api/3/user/search
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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why is the displayName email address?
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.