The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Statuspage http web request

Mike Abbe
April 12, 2021

Hello,

 

I am trying to use scriptrunner to sync JIRA and Statuspage using the API. I am able to get this to work within Automation for Jira using the Webhook action, but I needed to add logic in for multiple components. I took the exact header and body from the working Automation for Jira step but when I try to run it in groovy I can't get past compilation. 

Here is the code:



import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.POST
import static groovyx.net.http.ContentType.JSON

def incidentsURL = "https://api.statuspage.io/v1/pages/PAGEID/incidents/"
def http = new HTTPBuilder(incidentsURL)

return http.request(POST, JSON) { req ->
headers."Authorization" = "API_KEY"
body = [
{
"incident": {
"name": "{{issue.summary}}",
"status": "identified",
"metadata": {},
"deliver_notifications": true,
"body": "{{issue.description}}",
"components": {
"COMPONENTID_1": "degraded_performance",
"COMPONENTID_2": "degraded_performance"
},
"component_ids": [
"COMPONENTID_1",
"COMPONENTID_2"
]
}
}
]

response.success = { resp, json ->
assert resp.status == 200
log.debug("My response handler got response: ${resp.statusLine}")
if(htmlText){
return htmlText.getText()
}
else{
return null
}
}

// called only for a 404 (not found) status code:
response."404" = { resp ->
log.error ("Not found")
return null
}
}


I get this error:

Compilation error(s):
script_faebee5c347ccee6da33a12299bf286d.groovy: 18: expecting '}', found ':' @ line 18, column 13.
     "incident": {
               ^

 

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Kostiantyn Kyzymenko
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 9, 2022

@Mike Abbe Has it been resolved?
I actually facing a similar issue now

Mike Abbe
May 9, 2022

I don't believe I ever got this working. I ended up licensing Opsgenie and building the integration between Jira and Statuspage through there. 

0 votes
Joseph Chung Yin
Community Champion
April 12, 2021

@Mike Abbe -

Hi Mike:

In your code you have component_id mentioned twice -

     "components": {
"COMPONENTID_1": "degraded_performance",
"COMPONENTID_1": "degraded_performance"

Don't know if that was the cause of your error.

Best, Joseph Chung Yin

DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events