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!
Hi @Kyle Hollenbeck,
with the REST Jira's API you can only add one user for time.
So, if you want add more users as watchers, you must itering them and call the REST api more times.
You can't even add groups, as is possible with native Jira's API
Thanks for the reply @Andrea Pannitti!
In this case I'm only trying to add one watcher, but am either getting a 404 response or the wrong user added as a watcher (initiated user instead of the one associated with the accountId specified).
My initial summary line didn't articulate this well though, so I've updated it to make the issue I'm experiencing more clear 👍
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kyle Hollenbeck,
I noticed that the base url is missing in your REST call. Add it. I think this could solve your issue (to add one user only).
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.