Hi everyone,
I need to find a way to fetch the user strictly by the provided email using Jira Cloud REST API.
Yes, I’m aware of this discussion that suggests to use the GET/rest/api/3/user/search endpoint:
However, this doesn’t work for me because this endpoint returns rather suggestions then exact one-to-one match. I found out:
- For valid emails (i.e. some-user@domain.de) this endpoint searches strictly and the response can contain only 1 user if the user is found or can be empty if user is not found. That’s good.
- For formally valid emails but with not recognized top-level domain (i.e. some-user@domain.dee - Atlassian allows sign up with such emails so we should take into account that there are some users with pretty specific emails somewhere) this endpoint searches non-strictly and tries to suggest the most suitable options - the response can be empty, contain 1 or more then 1 user. That’s not what I want, I want to get an empty array or some error response if the user is not found with the specified email.
As a workaround, I can create the Forge app just to be able to use the GET/rest/api/3/user/email endpoint (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-email-get). I have to use this endpoint because some users can hide the email visibility and this is the only way to be guaranteed to receive the email.
With this endpoint, I can validate the response from the GET/rest/api/3/user/search endpoint by checking the suggested user actually has the target email.
While this workaround should work, it sounds really messy. Or I can start to validate email with the recognized top-level domains - I think that’s even worse.
I believe there is more simple approach.
That’s why I’m here.
Question:
- Is this possible to find the user strictly by email using Jira Cloud REST API?