Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

get JSON data value from GET API with TOKEN

Piyush_Annadate
Contributor
May 18, 2020

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

 

URL:  https://slack.com/api/users.lookupByEmail?token=<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":"piyush.live","tz":"Asia\/Kolkata","tz_label":"India Standard Time","tz_offset":19800}}

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

 

Type: JIRA SERVER

ScriptRunner - Yes

 

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

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*


def http = new HTTPBuilder('https://slack.com/api/users.lookupByEmail?token=xxxxxxxxxxxxxxx&email=piyush.1502@live.com')
http.request(GET) { requestContentType = ContentType.JSON
response.success = { resp, JSON -> return JSON
}
response.failure = { resp ->
return "Request failed with status ${resp.status}"
}
}

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Ste Wright
Community Champion
March 26, 2022

Hi @Fitzroy Joseph 

Is this in a Jira Service Management Project?

These instructions are for Cloud, but they should be relatively similar in Server:

  1. Go to Project Settings > Request Types
  2. Locate the Request Type which is set to require an approval
  3. Select to view the Workflow/Statuses, then view the Workflow
  4. Edit the Workflow
  5. Select the Status where an Approval is required
  6. Next to the Add Approval option, select Configure
  7. Ensure Approvals Required is set to 1 approval(s) - not all approvals
  8. Press Create/Save, then publish the Workflow to make these changes

^ This should fix the issue.

Let us know if this works for you!

Ste

TAGS
AUG Leaders

Atlassian Community Events