Request format for the add watcher REST API?

I’m trying to add a watcher to an issue but I can’t construct an acceptable request body.

The docs seem to suggest the request body should just be a string, but that generates a Bad Request response.

I’ve raised a bug about this but wanted to see if anyone else knows how to use this API endpoint?

Maybe this won’t help, but anyway…

I succeeded in adding a watcher to an issue in JIRA 7.0. To get it to work, I used HTTPie to submit the request, which failed with a 400 BAD REQUEST, as yours did, and then I edited the request in my debugging proxy (Charles) so that the body contains only a string. The raw content of the successful request was as follows:

POST /jira/rest/api/2/issue/ABC-7/watchers HTTP/1.1
Host: localhost.charlesproxy.com:2990
Accept-Encoding: gzip, deflate
Accept: application/json
User-Agent: HTTPie/0.9.2
Connection: keep-alive
Content-Type: application/json
Authorization: Basic ***************
Content-Length: 7

"admin"

Is a lone string even valid JSON? I dunno.

Wow.
It appears, like you’ve suggested and actually like the documentation example, that the request body needs the username with double quotes surrounding it.
But the request must also have the application/json header…

Yeah, I don’t believe that “admin” is valid JSON. HTTPie wouldn’t even let me create a request like that. It can be done pretty easily with AP.Request though.