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

Not returning emailAddress for users in API call

Ste404
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.
September 11, 2022

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
Prince Nyeche
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.
September 12, 2022

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.

Ste404
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.
September 12, 2022

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.

Ste404
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.
September 13, 2022

@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.

Prince Nyeche
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.
September 14, 2022

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 Ste404 likes this
Ste404
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.
September 14, 2022

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

Will keep digging, thanks for the link also.

Ste404
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.
September 15, 2022

I need to claim the domain!

0 votes
marc -Collabello--Phase Locked-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2022

Hi @Ste404 ,

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
AUG Leaders

Atlassian Community Events