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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

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!

Leaderboard

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
4,555,609
Community Members
 
Community Events
184
Community Groups

How to send HTTP post Request via Scriptrunner Post function to receive JSON response

Edited

Hi Everyone,

 We have done the integration from jira to pager duty.

When the ticket is created in jira, Automatically it should trigger the event in the pagerduty.

While adding the scripted post function during create transition getting below errors,

The variable [body] is undeclared, [variable response is undeclared] and No such property:messages for class: java.lang.object..

the following script as follows:

import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import groovy.json.JsonBuilder
import groovy.transform.BaseScript

if(issue.issueType.name=="ZIA OPS Escalation"){

def http = new HTTPBuilder("https://events.pagerduty.com/generic/2010-04-15/create_event.json")
def summary = issue.summary
def issueDetails = "ZIA OPS Escalation " + issue.key
def body
def issueJson = http.request(Method.POST, ContentType.JSON) {
body [ "service_key": "77011ebbefad47dd987f045636e04390","event_type": "trigger", "description": "summary", "details": "issueDetails"]
response.success = { resp, json ->
log.debug("PagerDuty Trigger Successful = " + json.messages)
}
response.failure = { resp, json ->
log.debug("PagerDuty Trigger Failed = " + json.messages)
}
}
}

1 answer

1 vote
serge calderara
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 29, 2020

@srikanth kocherlakota , I have the same problem when tetiing HTTP b uilder in script console, it says body, response, header are undeclared .

Did you find the problem?

regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events