Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get Email address from a user account with Jira API

serge calderara
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.
March 12, 2021

Dear all,

I have run the following script from script runner 

The userAccountId is retrieved from a UserPicker field

def user = get('/rest/api/2/user/email?accountId='+ userAccountId)
.header('Content-Type', 'application/json')
.asObject(Map).body

return user

The idea is to retrieve the email address of the given Account ID.

What is wierd out of this call of the API is that in the return Json I have no email address key.
In an other hand if I go to the profile of that user, then I can see that its email is correctly set.

 

Any idea why I cannot retrive the Email adress from my User Picker field ?

3 answers

1 accepted

1 vote
Answer accepted
serge calderara
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.
March 12, 2021

From your Atlassian instance go to the email profile visibility setting :

https://id.atlassian.com/manage-profile/profile-and-visibility

Then at the bottom of the page from the Contact section, change your email visiblility to Anyone

Carlos Chang
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.
August 6, 2024

I checked the visibility and set it to "You and admins", however, I still can't get emails through admin's token.
Does is rule apply only in the web view, not for tools like Postman?

0 votes
Sankalp Chugh
Contributor
April 19, 2023 edited

I have a better idea to get email id. You can use the below REST request. In this way, you don't need to change the visibility. You can see the documentation here.rest api for user details.PNG

This is the response
rest api for user details response.PNG

0 votes
Juan Manuel Ibarra
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.
March 12, 2021

Hi, i think that the problem is:

Captura de Pantalla 2021-03-12 a la(s) 10.11.44.png

Only apps that meets the Guideline can access to this information

serge calderara
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.
March 12, 2021 edited

@Juan Manuel Ibarra , as you can see first is that I am using the API version 2

I mange to find out the reason and it has nothing to do with the API but instead about the security and visibility parameters in the profile section

By changing Email visibility to anyone, the API return correctly the email address in the json response

regards

Like Juan Manuel Ibarra likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events