Work with Watchers

With HAPI, we've made it easy for you to work with watchers. 

Jira does not support adding watchers during issue creation (JRASERVER-5493). This limitation means watchers can only be added to issues after the issue has been created.

Add a watcher to an issue

Add a watcher to an issue as follows:

groovy
Issues.getByKey('SR-10').addWatcher('jdoe')

Image showing you how to add a watcher to an issue with HAPI

Remove a watcher from an issue

Remove a watcher from an issue as follows:

groovy
Issues.getByKey('SR-10').removeWatcher('jdoe')

Retrieve the watchers from an issue

Retrieve watchers from an issue as follows:

groovy
Issues.getByKey('SR-10').watchers
Video

Security

By default all watcher operations respect the permissions of the current logged in user. You may want to ignore permission checks with the overrideSecurity property:

In this example we're using the overrideSecurity property to ignore permission checks when adding a watcher to an issue.

groovy
Issues.getByKey('SR-10').addWatcherOverrideSecurity('jdoe')



Related content

On this page