How to prevent a JIRA Cloud App from becoming a Watcher after posting a comment via REST API

Hi,

We have a JIRA cloud app that posts comments to issues (interactive/post-function type activities). A side effect of this comment is that the “APP” user becomes a watcher of the issue. How can we prevent this?

Thanks
Chris

Hi @Chris_at_DigitalRose,

I don’t think there is a parameter that can be provided to ensure the app doesn’t become a watcher. I’ve created https://ecosystem.atlassian.net/browse/ACJIRA-2217 to address this.

After posting the comment, the app could unsubscribe as a watcher by calling DELETE /rest/api/3/issue/{issueIdOrKey}/watchers, but obviously this is less than optimal due to the extra API call.

A better solution is for the app to set a preference to avoid Jira adding the app as a watcher. To do this, the app can call PUT /rest/api/3/mypreferences specifying user.autowatch.disabled=true. You can make this call when your app receives the /enabled event and to ensure this occurs for existing app installations, you can change something basic in your descriptor such as the version property so that Marketplace triggers re-installs of the app in all tenants.

Regards,
Dugald

2 Likes

Thank you Dugald, I appreciate the idea to change the app user preferences, post /enabled, and will give that a try.

1 Like

Update. The enabled lifecycle hook worked perfectly. Unfortunately the mypreferences API (Both GET/PUT) threw a 403 when called as the application user. I did see a note that says not available to apps…

I was able to set addon properties from the App Properties API , so I think the routing/authentication is working.

Did I do something wrong, or any other ideas?

Thank you,
Chris

1 Like

Hi @Chris_at_DigitalRose,

Ah, I didn’t realise the mypreferences API could not be called by apps. It seems the only practical solution is dependent on https://ecosystem.atlassian.net/browse/ACJIRA-2217 being implemented.

Regards,
Dugald