Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I am unable to add a watcher with rest API

Sharath Prakash
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!
May 21, 2020

I am trying to add watchers to an issue using rest API in python below is my code

 

url = 'https://my-domain.atlassian.net/rest/api/3/issue/%s/watchers?accountId=%s' % (
issue_id, userid)

list_watchers_url = 'https://my-domain.atlassian.net//rest/api/3/issue/%s/watchers' % issue_id

username = 'user-email'

password = '<API_TOKEN>'

add_watcher = requests.post(url, auth=(username, password))

watchers_list = []

watchers_list_resp = requests.get(list_watchers_url,
auth=(username, password))

for i in watchers_list_resp.json()['watchers']:
watchers_list.append(i['displayName'])
print(watchers_list)

Since I use my email and API key, it only adds me as a watcher.

 

I am unable to set anyone else.

 

user_id in the URL is the account id from Atlassian and not email or name.

 

I also used the jira-python library and it bombs worse than this.

1 answer

0 votes
dev
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!
September 13, 2021

watcher = JIRA::Resource::Watcher.new(client, issue: issue)
watcher.save!(user_id)

worked via jira-ruby gem

Suggest an answer

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

Atlassian Community Events