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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,555,285
Community Members
 
Community Events
184
Community Groups

Get accountID using Scriptrunner Jira Cloud

Edited

Hi,

I am trying to get accountID using email.

When I use a simple REST API call with API tester - it's working fine.

But when I use scriptrunner - something goes wrong. Please help, I am new in groovy and sometimes it's hard to understand. Here is my code:

def userEmail = "oleksandr.melnyk@example.com"

def response = get('/rest/api/3/user/search?query=' + userEmail)
.header('Content-Type', 'application/json')
.asObject(Map)

logger.info('Id=' + response.body.accountId)

return response


 

 

1 answer

1 accepted

0 votes
Answer accepted
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 10, 2023

Hi @Oleksandr Melnyk 

String email = "test@test.com"

def url = "https://xxxxxx.atlassian.net/rest/api/3/user/picker?query=${email}"
def response = get(url).header('Authorization', 'Basic xxxxxxx').asObject(Map)
return response.body.users.accountId[0] 

Thank you! @Tansu Akdeniz 

 

String email = "test@rest.com"

def url = "/rest/api/3/user/picker?query=${email}"
def response = get(url).header('Content-Type', 'application/json').asObject(Map)
return response.body.users.accountId[0]

Suggest an answer

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

Atlassian Community Events