I created a script to be run as ScriptRunner Add-On User (which I understand auto creates authentication). I tried my own function but when this failed tried the example for Notify on Priority Change. Below I have replaced the real issue ID and email for confidentiality. The real issue ID exists and the email address I used is my normal work email address (cloud based with SSO (Single Sign On)).
Both fail with
2021-05-04 16:43:12.586 INFO - Serializing object into 'interface java.util.List' 2021-05-04 16:43:12.639 INFO - GET /rest/api/2/field asObject Request Duration: 554ms 2021-05-04 16:43:12.818 INFO - Sending email notification for issue <my issue ID> 2021-05-04 16:43:13.024 INFO - POST /rest/api/2/issue/90367/notify asString Request Duration: 203ms 2021-05-04 16:43:13.025 WARN - POST request to /rest/api/2/issue/90367/notify returned an error code: status: 400 - Bad Request body: {"errorMessages":["Can not deserialize instance of com.atlassian.jira.issue.fields.rest.json.beans.UserJsonBean out of START_ARRAY token\n at [Source: com.atlassian.plugin.connect.plugin.auth.scope.InputConsumingHttpServletRequest$1@541f4926; line: 1, column: 350] (through reference chain: com.atlassian.jira.issue.fields.rest.json.beans.NotificationJsonBean[\"to\"]->com.atlassian.jira.issue.fields.rest.json.beans.ToJsonBean[\"users\"])"]} 2021-05-04 16:43:13.026 INFO - Serializing object into 'interface java.util.Map' 2021-05-04 16:43:13.026 INFO - Run script completed
The script is
def resp = post("/rest/api/2/issue/<my issue ID>/notify")
.header("Content-Type", "application/json")
.body([
subject: 'Mail title',
textBody: "Body",
htmlBody: "<p>Body</p>",
to: [
users: [[
name: "firstname.lastname@mycompany.com",
active: true
]]
//groups: [[
// name: 'some group'
//]]
]
])
.asString()
Using api version3 I still need double square brackets:
def resp = post("/rest/api/3/issue/${issue.key}/notify")
.header("Content-Type", "application/json")
.body([
subject: 'Component Bug Notification',
textBody: message,
htmlBody: message,
to: [
watchers: true,
users: [[
name: '<my email address'
]]
]
])
.asString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.