Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,950
Community Members
 
Community Events
168
Community Groups

How to Add Watchers to an Issue?

Hello. So, I'm trying to add a particular person as a watcher to a number of issues via API, but it doesn't work.

According to this page https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/issue-addWatcher, (the `example` there is exceptionally helpful, btw), I'm supposed to send POST request to `/rest/api/2/issue/{issueIdOrKey}/watchers` with a `username` for a parameter. However, when I do that, my own user gets added to watchers, not the desired user that I send in params. I still get 204, which is a success code here.

URL I'm using:

('https://company.atlassian.net/rest/api/2/issue/issue_key/watchers', auth=auth, headers=headers, params=params)
headers = {
"User-Agent": "dummyValue",
"X-Atlassian-Token": "no-check",
"Accept": "application/json",
"Content-Type": "application/json",
}

params (with the email of the desired user)

{"username": "JoeSmith@company.com"}

What am I doing wrong?

P.S.: I'm kinda confused by the 'username' entity. When I get a user object via API, it has 'emailAddress', 'accountId' and 'displayName' parameters, - but not a `username`. What's up with that?

1 answer

1 vote

You're using an old doc. Cloud instances deprecated username. Therefore, you should use accountId if you want to add watchers to an issue. See this official doc for an example.

@Prince NyecheHey, by any chance, do you know how to deal with the authorization issues? I reworked the code, and now I'm getting 403 (not enough permissions), even though I'm admin on the project in question, and also explicitly added myself to the permission schema, 'manage watchers' section.

Are you able to edit the issue field? Check if you have permission for that.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events