I'm attempting to clone an issue using a Scriptrunner post-function and have had success copying over everything to the new issue except for "watchers".
My first attempt followed the recommendation on the support site as below:
def addWatcherResp = post("/rest/api/2/issue/clonedIssue.id/watchers")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.body('"${accountId}"')
.asObject(Map)This consistently gives a "404 - Not Found error" response
I then tried the following:
def addWatcherResp = post("/rest/api/2/issue/clonedIssue.id/watchers?=${accountId}")
.asObject(Map)which almost worked except it's only the "Initiating User" (so either Scriptrunner or the triggering user) that gets added as a watcher, not the accountId specified. I've tried several variations of this with no luck.
Interestingly, deleting an issue like below works fine for whatever user is specified:
def deleteWatcherResp = delete("/rest/api/2/issue/clonedIssue.id/watchers?accountId=${accountId}")
.asObject(Map)Not really sure why this isn't working, but I'm about ready to give up on Scriptrunner for watcher management and create a branching link-triggered automation rule instead.
Any insight or help would be greatly appreciated, thanks!