Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

0 votes
Kostiantyn Kyzymenko 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events