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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.