Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Cloud API - Getting a user in Java by email address

I'm using the Jira Cloud OpenAPI v2 in Java through this guide here: https://blog.developer.atlassian.com/update-to-jira-clouds-swagger-openapi-docs/

I'm trying to return a user by inputting his mail adress, but it doesn't work:

UsersApi usersApi = new UsersApi(apiClient);
User user = usersApi.getUser("example@mail.com", null, null, null);

 It says something about not finding anyone with that ID, I guessed that he needed the Atlassian user ID. I also tried this:

UserSearchApi userSearchApi = new UserSearchApi(apiClient);
PageBeanUser pageBeanUser = userSearchApi.findUsersByQuery("example@mail.com", 0l, 50);

But that doesn't work either.

How can I return an user when I have his e-Mail?

1 answer

0 votes
Daniel Eads Atlassian Team May 03, 2021

Hi @Patrick Fabian ,

Due to GDPR changes, you'll need to use a query parameter to search email addresses. An example is provided at the REST API endpoint Get User . I've copied the Java code example and modified it (on the documentation, it uses an Account ID string) to show how email might be used as the search parameter:

// This code sample uses the 'Unirest' library:
// http://unirest.io/java.html
HttpResponse<JsonNode> response = Unirest.get("https://your-domain.atlassian.com/rest/api/2/user")
.basicAuth("email@example.com", "<api_token>")
.header("Accept", "application/json")
.queryString("search", "example@mail.com")
.asJson();

System.out.println(response.getBody());

Do note that depending on a user's privacy settings on their Atlassian account, you might not be able to access the email address. Hope that helps!

Cheers,
Daniel

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

95 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you