Hi all,
I use Scriptrunner to send MS Teams (and Slack) notifications when some issues are transitioned. The problem is, that MS Teams notifications only work for certain Jira(/Microsoft) users (e.g. mine), and not for others.
When the notification fails, I get a 400 error.
Here's my Scriptrunner groovy code:
def notificationChannel = "https://XXXXXXXXXX.webhook.office.com/webhookb2/XXXXXXXX/IncomingWebhook/YYYYYYYYYYY/ZZZZZZZZZZZZZZ"
try {
def post = new URL(notificationChannel).openConnection() as HttpURLConnection
def teamsMessage = "{'text':'"+notificationMessage+"'}"
post.setRequestMethod("POST")
post.setDoOutput(true)
post.setRequestProperty("Accept", 'application/json')
post.setRequestProperty("Content-Type", "application/json")
post.getOutputStream().write(teamsMessage.getBytes("UTF-8"))
def postRC = post.getResponseCode()
if (!postRC.equals(200)) {
throw post.getInputStream().getText()
}
} catch (err) {
SlackUtil.message("slack_connector",
Constants.ERROR_NOTIFICATION_CHANNEL,
"<!channel>\n"+err.getMessage()
)
}
When it fails, the returned error is:
Server returned HTTP response code: 400 for URL: https://XXXXXXXXXX.webhook.office.com/webhookb2/XXXXXXXX/IncomingWebhook/YYYYYYYYYYY/ZZZZZZZZZZZZZZ
If I open the same issue with my Jira users, and execute the same transition, the notification goes fine.
Any hints?
Thanks in advance!