Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

How to Authenticate for Get user account with REST API

Dear all,

I am trying to get information about a user account from a UserPicker custom field

For that I have a custom field User Account available and I am able to retrive its information as seen below :

{self=https://host.atlassian.net/rest/api/2/user?accountId=5c0f8b8c3acad8551c338a8f, accountId=5c0f8b8c3acad8551c338a8f, avatarUrls={48x48=https://secure.gravatar.com/avatar/2a8975f9d7252b7640b127c1e6846f2f?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSC-6.png, 24x24=https://secure.gravatar.com/avatar/2a8975f9d7252b7640b127c1e6846f2f?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSC-6.png, 16x16=https://secure.gravatar.com/avatar/2a8975f9d7252b7640b127c1e6846f2f?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSC-6.png, 32x32=https://secure.gravatar.com/avatar/2a8975f9d7252b7640b127c1e6846f2f?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSC-6.png}, displayName=Tom smith, active=true, timeZone=Europe/Zurich, accountType=atlassian}"

when I am running the first call inside Script runner console, I am running is as Current user which is my Admin account

Then from that account information, I need to retrive the user email. For that I was using the following code below :

String userAccountId=issuefields[customFieldObject.id].accountId

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

Please note that the variable userAccountId is containing correct account value 5c0f8b8c3acad8551c338a8f

When I am executing this request, I get the following error :

{errorMessages=[Specified user does not exist or you do not have required permissions], errors={}}"

 

Any idea what I am doing wrong as the account is existing and the script is executing as current user which as Admin write.

Do I need to authenticate differenly for that user endpoint ?

Thanks for help

regards

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

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