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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

get JSON data value from GET API with TOKEN


I'm trying to fetch an API return; result in JSON FORMAT. Using ScriptRunner JOB - will that be possible to have those results.


URL:<sometoken>&email=<value that I'll provide>


I would like to have this return value of a particular element. i.e. ID (bold below)


{"ok":true,"user":{"id":"U013MMEPMHC","team_id":"<someother>","name":"piyush.1502","deleted":false,"color":"e7392d","real_name":"","tz":"Asia\/Kolkata","tz_label":"India Standard Time","tz_offset":19800}}

 I may need the whole sort of line code to figure this out. 



ScriptRunner - Yes


With Below: Able to fetch the data - but how to only extract the required field and save it in a variable.

import static*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
import static*

def http = new HTTPBuilder('')
http.request(GET) { requestContentType = ContentType.JSON
response.success = { resp, JSON -> return JSON
response.failure = { resp ->
return "Request failed with status ${resp.status}"

1 answer

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 23, 2020

I've edited your question to remove the token from your code block... you probably want to keep that private.

But the response.success is already parsing the JSON for you into a nice object structure.

You could just add after the last curly brace, but something like this will be safer:

def responseObj

def http = new HTTPBuilder('')
http.request(GET) {
requestContentType = ContentType.JSON
response.success = { resp, JSON ->
responseObj = JSON
response.failure = { resp ->
responseObj= [error: "Request failed with status ${resp.status}"]
userId =

Thanks @Peter-Dave Sheehan . For the token and the answer. 

I updated it as 


responseObj = JSON.user ? : null

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events