Discussion:
Jira Rest Java Client (JRJC), addWatcher function usage
forums-YrDk4eUcT3KaMJb+
14 years ago
Permalink
Has anyone successfully used the addWatcher function from the new Jira Rest Java Client (JRJC) Library?

I opened a jira issue ([http://studio.atlassian.com/browse/JRJC-15|http://studio.atlassian.com/browse/JRJC-15]) in the JRJC jira project where you can see my code, my pom dependencies, the output, and the stacktrace. The developer hasn't been able to reproduce the problem I'm having. I figured I'd give the forums a try as well...

Please let me know how to proceed.
Thanks,
Colin
--
Post by ckinder - online at:
http://forums.atlassian.com/thread.jspa?forumID=100&threadID=52057
forums-YrDk4eUcT3KaMJb+
14 years ago
Permalink
OK, here's an easier question that takes much less setup... has anyone used REST via curl to add watchers before? I can't get that to work either.

*REST calls that work for me* (get available transitions, close an issue, add myself as a watcher)
{code}curl -X GET -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/transitions
curl -d '{"transition" : 2,"fields" : { "resolution" : "Fixed" },"comment" : "POST worked!"}' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/transitions
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers{code}

*REST calls to add a watcher that fail*
{code}curl -d '{michael}' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers
curl -d '{"michael"}' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers
curl -d "michael" -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers
curl -d '{"username" : michael}' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers{code}

In each case the response is the following:
HTTP Status 400 - The request sent by the client was syntactically incorrect ().

Is anyone able to add a watcher to an issue via REST?

Thanks,
Colin
--
Post by ckinder - online at:
http://forums.atlassian.com/thread.jspa?forumID=100&threadID=52057
forums-YrDk4eUcT3KaMJb+
14 years ago
Permalink
What about:

{code}
curl -d '"michael"' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u ckinder:mypass http://localhost:8080/jira/rest/api/2.0.alpha1/issue/TST-943/watchers
{code}

The username needs to include the "" to be valid JSON.
--
Post by luis - online at:
http://forums.atlassian.com/thread.jspa?forumID=100&threadID=52057
forums-YrDk4eUcT3KaMJb+
14 years ago
Permalink
Yep, that does indeed work. Thanks for helping me out with that. As I'm sure you guessed, I'm new to JSON and was winging it from the few examples I could find :)
--
Post by ckinder - online at:
http://forums.atlassian.com/thread.jspa?forumID=100&threadID=52057
Loading...