Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,637,364
Community Members
 
Community Events
196
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
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 17, 2022

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.

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 18, 2022

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

Apoorva N
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Sep 14, 2023

@Prince Nyeche i am trying to use the updated doc and i am not able to get accountId param. Many people mention using Find users api and when i do that i only get jira key and not account id. also i tried groupuserpicker api - even this only gives jira key and not accountId. any idea why this would be happening?

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 14, 2023

You can use the searchUser API to return the account of any user within your environment. You have to parse the output to get the accountId key value. An example is shown on the docs

Suggest an answer

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

Atlassian Community Events