Hoping someone can help with the below request:
I am trying to add a group of people as watchers at time of ticket creation. I have tried both of these codes and they are failing.
Based on issue type:
if (issue.fields.issuetype.id == "11200") {
def issueKey = issue.key
def members = get('/rest/api/2/group?groupname=chewy-brands&expand=users').asObject(Map).body.users.items
//ADD ENTIRE GROUP TO ISSUE AS WATCHERS
for (def i = 0; i < members.size(); i++) {
post("/rest/api/2/issue/" + issueKey + "/watchers")
.header('Content-Type', 'application/json')
.body("\"" + members[i].name +"\"")
.asString()
}
}
Based on request type:
def issueKey = issue.key
if (request) {
if (request.requestType.id == '176') {
// GET ALL MEMBERS OF THE pharmacy group
def members = get('/rest/api/2/group?groupname=pharmacypromo&expand=users').asObject(Map).body.users.items
// ADD ENTIRE GROUP TO ISSUE AS WATCHERS
for (def i = 0; i < members.size(); i++) {
post("/rest/api/2/issue/" + issueKey + "/watchers")
.header('Content-Type', 'application/json')
.body("\"" + members[i].name +"\"")
.asString()
}
}
}
*ERROR MESSAGE: [request] and [issue] are both undeclared