Pulling my hair out here. I can’t figure out how to add a watcher either in Issue Creation or Issue edit. How do I format the JSON for this?
As per JRASERVER-5493, you can’t add a watcher during Issue creation with Jira SERVER.
As per the How to ask a good question thread, please provide the full example of how you tried to add a watcher to an Issue after the Issue was created. Include the full request in the code language you are using and any errors / responses you are getting. Also, which version of Jira Server are you using?
As sunnyape already mentioned here HELP - adding a watcher using REST API JSON - #2 by sunnyape it is not possible to do this during issue creation step (and neither during issue editing). In jira itself it is also done by a separate REST call
Based on the documentation here: Jira 9.4.0
You only have to send the user name as a string:
POST /rest/api/1.0/issues/<ID_OF_ISSUE>/watchers HTTP/1.1
Also don’t forget to check the permissions of the project: Managing project permissions | Administering Jira applications Data Center and Server 9.4 | Atlassian Documentation
→ Manage watcher list - Permission
notice that the ability to add watchers in the create screen (and therefore also in other transitions) appears in Jira 9.13 (To use this feature, the admin needs to enable the feature flag)
You might want to re-read that release note, as it applies to Jira DATA CENTER, not Jira SERVER:
“Starting from 9.13.x, new releases of Jira will be available only to Data Center customers.”
Given the OP has tagged their question as relating to Jira Server, that release would not be available to them.
In your post, you provided a link to the Jira Server v9.4.0 REST API documentation, which says the Issue - Add watcher endpoint is used as follows:
but you provided a code sample and a screen grab from a Postman session showing that the endpoint for adding a member to an issue is used as follows:
There is no v1.0 of the Jira Server REST API and the URL to the endpoint is different (note the singular ‘issue’ vs ‘issues’). If I try to access that endpoint as you’ve described, I get a 404 Bad Request response.
- Which documentation did you get that URL for that endpoint from?
- Please provide a complete screen grab from your Postman session showing where you executed that request to that endpoint and got a 204 No Content response to prove it worked correctly
You are correct. I just pointed to the documentation but used the rest call which is used by jira itself when using the add watcher functionality in the browser.
Here is the requested working example
POST /rest/api/2/issue/<ID_OF_ISSUE>/watchers HTTP/1.1
Thank you everyone this has worked. So for clarity, if anyone else is looking - there is no JSON format - at least not as we know it. Simply put the username in quotes.
Thanks Christian. I can’t argue with an Internet Standard!