Rest API - Add Issue Watcher to an Issue

Is it possible to add a watcher (or multiple watchers) via Rest API to an Issue? We've tried adding a watcher via API, but everytime we called POST on an Issue with a watcher in request content. Body looked like:

{
    "watchers": {
        "hasStar": true,
        "issueWatchers": [
            {
                 "user": {
                       "login": USER_LOGIN_HERE,
                       "$type": "jetbrains.charisma.persistence.user.User"
                  },
                 "$type": "jetbrains.charisma.persistent.issue.IssueWatcher"
            }
         ],
        "$type": "jetbrains.charisma.persistent.issue.IssueWatchers"
     }
}

Watcher was added, but it was always our user (user whose token was used to call the API). Is it possible to add different user as a watcher using the same token?

1 comment
Comment actions Permalink
Official comment

Hello Daniel,

I'm sorry for the delayed response.

Here's the example of a request to add a watcher:

You can add other users as watchers via command: `start <user_login>`. Here you can learn how to apply commands via REST: https://www.jetbrains.com/help/youtrack/incloud/resource-api-commands.html#create-CommandList-method

POST https://<base_url>/api/commands

{
"query": "star <user_login>",
"issues": [
{
"id": "<issue_id>"
}
]
}

Let us know if you need any assistance, we'll be happy to help.

Please sign in to leave a comment.