Groovy REST API call Response

Naman Mandli
Contributor
March 1, 2019

import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method

def remote = new HTTPBuilder("https://myjiraurl")
def issueJson = remote.request(Method.GET) { req ->
uri.path = "/api/v1/token"
headers.'Authorization' =
"Basic ${"username:password".bytes.encodeBase64().toString()}"

response.success = { resp, json ->
json ?: [:]
}
}

I am using above groovy code and able to get following output:

[access_token:9hf5ba12-c78a-48b4-a8e9-20d75ecgb552, code:200]

 

Now I want to hit another REST API and use above access_token in header to get JSON data. And from that JSON data I want to parse one field.

 

Can someone PLEASE help?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events