You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
@grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.JSON
try{
def rest = new RESTClient('https://status.cernerops.com')
String token = '<bearer token>'
def response = rest.get(
path: '/api/incidents?q=jira2&unresolved=',
headers: [Authorization: "Bearer ${token}"],
requestContentType: JSON )
response.responseData
} 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.
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'
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'
}).toString()
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/","https://status.cernerops.com/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 {
ArtInstField.clearHelpText()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.