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

Scriptrunner pulling back External API

@grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )

import static

def rest = new RESTClient('')
String token = '<bearer token>'
def response = rest.get(
path: '/api/incidents?q=jira2&unresolved=',
headers: [Authorization: "Bearer ${token}"],
requestContentType: JSON )


} catch(Exception ex) {

log.warn "Error: ${ex.message}"



Keep getting a 401 like the authorization is not passed.  Works in postman but not from my script.

1 answer

0 votes
John Chin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 07, 2021

Hi @Kevin Dalton ,

Do you see the same 401 response error using our library script? If yes, could you please test with curl command in the JIRA server instance and verify if its still hitting the same problem?

We were able to figure it out.  Stupid Headers ;)

http.request(GET, JSON) { req ->
uri.path = csdincident+svcSearch
headers.'Authorization' = "Bearer $access_token"
headers.'Content-Type' = 'application/json'
headers.'User-Agent' = 'Mozilla/5.0'


Like John Chin likes this

Short and sweet.  We call the API of our incident management applications.

if (tool.toString().contains('JIRA1')) {
def svcSearch = '?service_id=' + JIRA1 + '&unresolved=true'
def GETsearch = ( http.request(GET, JSON) { req ->
uri.path = csdincident+svcSearch
headers.'Authorization' = "Bearer $access_token"
headers.'Content-Type' = 'application/json'
headers.'User-Agent' = 'Mozilla/5.0'

if (GETsearch.size() > 2){
String[] variables = GETsearch .split(",");
String name = variables[1];
def namefix = name.replaceAll("name:","")
String contract = variables[3];
def contractfix = contract.replaceAll("contracts:/api/incidents/","").replaceAll("/contracts]]","").replaceAll("/contracts]","")
HELP = HELP + '<a href="' + contractfix + '">' + namefix + '</a><br><br>'

Then we do some parsing of the JSON to build a nice big red box informing our users on create that there is an incident.

if (HELP.toString()){
HELP = HELP.substring(0, HELP.length() - 8)
ArtInstField.setHelpText('<p style="border:3px; border-style:solid; border-color:#FF0000; padding: 1em;">There is a known incident/s logged to CSD please refer to the following.<br><br>'+ HELP + '</p>')
else {


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events