Hi, I am trying to update watcher field using Script-runner but can't seem to find the right way to do it.
def issue = "DEMO-1"
def result = put('/rest/api/2/issue/' + issue)
.header('Content-Type', 'application/json')
.body([
fields:[
"watchers" : [
"testuser1",
"testuser2"
]
]
])
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
Error-returned:
Serializing object into 'interface java.util.Map' GET /rest/api/2/issue/DEMO-1 asObject Request Duration: 698ms 2 [testuser1, testuser2] PUT request to /rest/api/2/issue/DEMO-1 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"watchers":"Field 'watchers' cannot be set. It is not on the appropriate screen, or unknown."}} PUT /rest/api/2/issue/DEMO-1 asString Request Duration: 237ms
Watchers is not a field, it's a system generated user list.
See https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-addWatcher
Well, I got the POST request working fine. Since Atlassian Cloud API does not support UPDATE request watchers yet it cannot be implemented.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.