Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crucible REST API: Can't add reviewer

I am trying to use the Crucible REST API to add reviewers to a review that I've just created (also using REST).According to the Atlassian docs, I should a POST to:

/rest-service/reviews-v1/{id}/reviewers

with what? The docs don't show a valid request for adding reviewers. When you click on 'expand' it doesn't show anything, it just says "Comma separated reviewers" which doesn't seem to work.

I've tried:

user1,user2

{"user1","user2"}

{reviewers:[reviewer:{"userName":"user1"},reviewer:{"userName":"user2"}]}

All of these result in the following response:

{"code":"NotFound","message":"The user named '{\"user1\"' is not a Crucible user.","stacktrace":"com.atlassian.crucible.spi.services.NotFoundException: The user named '{\"user1\"' is not a Crucible user.
at com.atlassian.crucible.spi.impl.DefaultReviewService.getUser(DefaultReviewService.java:2011)
at com.atlassian.crucible.spi.impl.DefaultReviewService.access$3500(DefaultReviewService.java:95)
at com.atlassian.crucible.spi.impl.DefaultReviewService$32.doInTransaction(DefaultReviewService.java:1973)
at com.atlassian.crucible.spi.impl.DefaultReviewService$32.doInTransaction(DefaultReviewService.java:1965)
at com.atlassian.fisheye.spi.impl.DefaultTxTemplate.execute(DefaultTxTemplate.java:123)
at sun.reflect.GeneratedMethodAccessor1317.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
...

That stacktrace goes on and on and on....

user1 and user2 are valid names because I can see them on other reviews when I do a GET to the same URL.

Anyone have any ideas?

Thanks!

like image 444
Jon Avatar asked Oct 21 '22 14:10

Jon


1 Answers

Well, for what it's worth, here is how to add reviewers to an existing review:

  1. do a POST to Crucible URL: protocol://server:port/context/rest-service/reviews-v1/{id}/reviewers

  2. the body of the post should contain the literal value: user1,user2,user3

  3. Resist the urge to JSON-ify the data - no quotes, no brackets, labels, etc. It's literally a comma separated list of the usernames to be added.

  4. Do not expect a response from the server, it seems to return a status code of 204. While this is acceptable as a restful response, it just seems odd since many other URLs for this API do return something when you do a POST to confirm that the work was completed.

In fairness to Atlassian, the docs do spell out the data to be sent:

"a list of comma separated reviewers"

But the docs should probably be updated with an example since I think it would be normal for someone (at least for me) to assume that when using a RESTful API, they need to format the data as JSON. Also, the docs should spell out more discreetly that the server doesn't send a response on success. That is, IMHO.

Hope that helps someone!

like image 151
Jon Avatar answered Oct 27 '22 08:10

Jon