Forums

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

Getting incorrect results for user search query by email

Umesh Kumar April 14, 2020

I'm trying to get the JIRA user object using the endpoint

http://domain.atlassian.net/rest/api/2/user/search?query='email'

When I try to search using the actual email 'a.b@example.com' I don't get any results for the user ( but a status 200 OK ), but if I change the email to 'a@example.com' I get the proper user object.

If someone could point me in the correct direction.

I'm trying the request via postman at the moment and using basic auth for all the requests.

2 answers

1 vote
Nir Haimov
Community Champion
April 14, 2020

Hi,

I think this search work by username or userKey, not by email

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2020

Hi @Umesh Kumar  and Welcome to the Atlassian Community!

@Nir Haimov  is correct about the search, and here is the documentation on that API call:

https://docs.atlassian.com/software/jira/docs/api/REST/8.5.4/#api/2/user-getUser

Best regards,

Bill

Like Umesh Kumar likes this
Umesh Kumar April 14, 2020

Thanks @Bill Sheboy .

JIRA 8.5.4 2020-04-14 19-50-00.jpg

 

Um, ok. So basically string passed tries to match the username or email or name and returns the result? Yeah that'd make sense, I read it wrong maybe because I was looking for an easy answer :D

@Nir Haimov @Bill Sheboy  Is there a possible way to search users by email, maybe by query?

0 votes
Umesh Kumar April 14, 2020

I think I figured it out, I can use the same search and iterate through results to match the email address and remove any duplicates. Except that the user object wasn't returning email address in the response obtained from JIRA.

 

Perhaps that's related to permission issue of the account being used for querying JIRA?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2020

Hmmm...

Yes, if you use the email id alone this should work.  For your example of an email address of a.b@example.com

http://domain.atlassian.net/rest/api/2/user?username=a.b

You can rapidly test this with your own email address versus user name.  The query string is just the same for both, as you noted.

If the email addresses you are searching for are not unique, due to the domains being different, you may want to follow up with support about how to proceed.

Umesh Kumar April 14, 2020

@Bill SheboyEmail addresses are unique but the search doesn't works as expected.

So for the email address: a.b@example.com, I tried the query string "a.b@example.com" and "a.b" both didn't give me the results. But If I change the query to "a@example.com" or just "a", rather even "a b" it works fine which is bit weird.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2020

Thanks, and sorry that I could not be of more help.  I suggest pinging Atlassian support as this may just be a syntax issue that is missing from the documentation (or a defect), and after a few searches I could not find examples to help you.

Umesh Kumar April 14, 2020

@Bill Sheboythat's not a problem at all, you were definitely helpful :) Thank you so much.

Have a great day!

Suggest an answer

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

Atlassian Community Events