Hello all!
I have a few script listeners that send out notifications to certain users, and they're working fine with a single user.
Now, I need to pull users from a user-picker field and send notification to them.
The API for the notification states this as a possible parameter for sending notifications:
Array<UserDetails>
List of users to receive the notification
example=
{
"accountId": "<string>"
}
This is the code I have. 'Approvers' is the custom field I need to pick users froms
def issueKey = issue.key
def result = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
def approvers = result.body.fields.customfield_10067.accountId as List<Map>
def resp = post("/rest/api/2/issue/${issueKey}/notify")
.header("Content-Type", "application/json")
.body([
subject: "test"
textBody: "body",
htmlBody: "Hello",
to: [
users: [[
accountId: approvers,
active: true
]]
]
]).asString()
The code runs fine, but the notification is not sent because 'there are no recipients'. I know i'm doing something wrong with how I get the multiple users and/or how I pass them under the 'to:' part of the code, but I'm out of ideas and completely stuck at this part!
I have also tried to get the value for def approvers as a string, using
def approvers = result.body.fields.customfield_10067.accountId as String[ ]
but I still get the same error.
I'll appreciate any help on this matter! Thanks!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.