Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,103
Community Members
 
Community Events
168
Community Groups

Not returning emailAddress for users in API call

Hi there,

I am building this API call to build an export of Jira users

Here is part of the call from a get-Atlasusers function I created.

$results = @()
while ($true) {
$url = "https://$workspaceName/rest/api/3/users/search?startAt=$startAt&maxResults=$maxResults"

$result = Invoke-RestMethod -Uri $url -Headers $headers

I have a for each which loops through the results then creates a CSV of Atlassian ID, Name and email address, but I am getting null for email address.

 

I am calling my function here (a subset here)

 

$AT_users = Get-AtlassianUsers $token

$export = @()
foreach ($AT_user in $AT_users) {
try {

$export += [PSCustomObject]@{
Atlassian_ID = $AT_user.accountId
Name = $AT_user.displayName
email = $AT_user.emailAddress

 

I am not sure why I am getting results except for email address here?

 

2 answers

0 votes

E-mail address API is only available if you're an app vendor, see details here and access to it was removed due to GDPR. So if you're simply using this just for your organization. I'll suggest you go with the organization API instead if you want to get the email addresses of users within your organization. Otherwise, you can inform your users to tweak their personal privacy settings and share their email addresses with the administrator so it becomes visible. The former seems to work better in your use case.

Thanks, I was trying that with my own test instance and keep getting a 401..  but when I do the same thing just with the users it works fine just no email.

Will have to see what I need to change auth wise I think.

@Prince Nyeche yeh I am stuck.  I have everything in place (I think) bearer token using the API Key I generated from the admin.atlassian page, I have the org ID from the site, I plug in the GET..    401 every time.

That would be the wrong API to use, you need to generate an API from https://id.atlassian.com/manage-profile/security/api-tokens if you want to access that endpoint.

Like Steven Lees-Smith likes this

Hmm ok I am getting a 200 now (tick), just not getting any users back?!

Will keep digging, thanks for the link also.

I need to claim the domain!

Hi @Steven Lees-Smith ,

Not sure, but I believe you need to apply to Atlassian for access to email addresses.  My recommendation is to contact support.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS

Atlassian Community Events