Bhavya-org / Scripts

0 stars 0 forks source link

Send e-mail upon creation (MS) #64

Open pramodhm112 opened 3 days ago

pramodhm112 commented 3 days ago

def issueKey = issue.key

def requestBody = [ subject: "${issue.key} was just created!", htmlBody: "${issue.fields.summary}", to: [ users: [ accountId: "60e1194fcf1849006a08bbda" ] ] ]

def resp = post("/rest/api/2/issue/${issueKey}/notify") .header("Content-Type", "application/json") .body(requestBody) .asString()

// Handle response if (resp.status == 200) { println "Notification sent successfully." } else { println "Failed to send notification. Status code: ${resp.status}, Response body: ${resp.body}" }

Bhavya-ss commented 3 days ago

def issueKey = issue.key

def notify = post("/rest/api/2/issue/${issueKey}/notify") .header("Content-Type", "application/json") .body([ subject: "${issue.key} was just created!", htmlBody: "${issue.fields.summary}", to: [ users: [ [ accountId: "63060b97189e0a3a4ff283dc" ] ] ] ]) .asString()

print "Notification Result: ${notify}"