Forums

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

Adding watchers using REST API returns 404

Renato Teixeira March 17, 2020

I am trying to add a watcher to an issue but I always run into 404. I believe this has worked before.

 

I am doing it in python but see below the curl command:

 

curl -i -u user:<APPKEY> -H "Content-Type: application/json -X POST -d '"myusername"' https://hostname/rest/api/3/issue/KEY/watchers

 

HTTP/1.1 404

Server: AtlassianProxy/1.15.8.1

Vary: Accept-Encoding

Cache-Control: no-cache, no-store, no-transform

Content-Type: application/json;charset=UTF-8

 

I have tried version 2 of the API as well. What is wrong with it? Is it a Jira bug?

 

Thank you

Renato

5 answers

1 accepted

1 vote
Answer accepted
Renato Teixeira April 24, 2020

I solved by doing this:

 

curl -i -u user:<APPKEY> -H "Content-Type: application/json" -X POST -d '"accountId"' https://hostname/rest/api/3/issue/KEY/watchers

 

Using accountId did the trick here.

1 vote
Renato Teixeira April 24, 2020

Deleted comment

1 vote
Randy
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.
March 17, 2020

404 means the issue doesn't exist or the user account doesn't have permissions.  It should have returned an error message saying as such.

 

Does the issue exist?  Does the user have permissions to watch the issue?

Renato Teixeira March 19, 2020

Additional facts:

* the issue exists;

* the user exists;

* the requesting user has permissions (MANAGE_WATCHERS);

* The body response is: {"errorMessages":[],"errors":{}}

Randy
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.
March 19, 2020

are you able to see the issue via https://hostname/rest/api/3/issue/KEY ?

Renato Teixeira March 19, 2020

Thanks for the hint. That led me to this:

$ curl ... https://hostname/browse/KEY

200 ...

$ curl ... https://hostname/rest/api/2/issue/KEY

{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}

Seems like I can't access it with rest api but with /browse I get the result. This suggests that the error is not on the watchers endpoint (even though the error message was unclear).

Renato Teixeira March 20, 2020

The issue is not solved yet. Can someone help ?

Randy
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.
March 31, 2020

are you using your email for the username?

Renato Teixeira April 1, 2020

I tried both username and email.

Renato Teixeira April 24, 2020

Ok I figured this out by connecting the dots while working in some other Jira issue. Instead of using your username and email, you must set the accountId instead.

I guess that change must have been introduced recently due to GDPR concerns that also affected other Jira endpoints. I have not seen this change documented anywhere...

tobias.fielitz
Contributor
August 18, 2021

I am having the same issue for the python library: https://github.com/pycontribs/jira/issues/1123

0 votes
Renato Teixeira April 24, 2020

Deleted comment

0 votes
Renato Teixeira April 24, 2020

Deleted comment

Suggest an answer

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

Atlassian Community Events