Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

crucible review rest api using json

dhandu May 8, 2012

Hi, I am trying to generate a review, I am getting 404 Not Found{"status-code":404}, earlier I got 500 internal error, Please let me know any issues on parsing the data below. How can I generate the review and add changeset using this rest api

use LWP::UserAgent;
use HTTP::Request::Common qw(POST);

my $client = LWP::UserAgent->new;
my $data =<<'EOF';
POST /rest-service/reviews-v1 HTTP/1.1
Host: http://localhost:8060/crucible
Content-Length:
269
Authorization: Basic am9lOmpvZQ==
Accept: application/json
Content-Type: application/json

{"createReview":
{"reviewData": {
"allowReviewersToJoin":false,
"author":{"userName":"test"},
"creator":{"userName":"test"},
"moderator":{"userName":"test"},
"description":"JSON Review",
"metricsVersion":1,
"name":"readme ",
"projectKey":"CR"},
"patch":"Adding a patch"}
}
EOF

my $body = '{"CreateReview":{"repository":"TEST","patch":"$data"}}';

my $response = $client->request(POST 'http://localhost:8060/crucible/rest-service/reviews-v1/TEST-1/CreateReview', 'Content-Type' => 'appl
ication/json', 'Content' => $body);

print $response->status_line;
print $response->content;

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Mike Gutman - Cisco September 10, 2012

curl -X POST --cookie "remember=INSERT_TOKEN" -H "Content-Type: application/xml" -H "Accept: application/xml" --url "http://HOST:PORT/rest-service/reviews-v1" -d @newReview.xml

newReview.xml:

<createReview>

<reviewData>

<author> <!-- required element -->

<userName>migutman</userName>

</author>

<creator> <!-- required element -->

<userName> migutman </userName>

</creator>

<moderator> <!-- required element -->

<userName>migutman</userName>

</moderator>

<description>These is the Statement of Objectives.</description>

<name>Title of the new review</name> <!-- required element -->

<projectKey>CR</projectKey> <!-- required element -->

<allowReviewersToJoin>true</allowReviewersToJoin>

<state>Review</state>

</reviewData>

</createReview>

dhandu October 9, 2012

thank you, Please share the options for uploading the files and directory structure for review files , is there a way I can add changset without push using restapi option,

curl -X POST --cookie "remember=INSERT_TOKEN" -H "Content-Type: application/xml" -H "Accept: application/xml" --url "http://HOST:PORT/rest-service/reviews-v1" -d @newReview.xml

0 votes
Gopinath Velayudhan June 28, 2012

i got it working. I have posted by Code in another link

Updating Crucible comments using REST API

http://host:port/context/rest-service/reviews-v1/{id}/addChangeset [P">Adding Changeset to Crucible review using REST API

dhandu July 1, 2012

Thanks Gopinath, do you have sample for create a review using the rest API ? Do you have information about authentication using soap , during review I dont want user need to enter thier windows password . I am using curl for upload the file .

Thanks

0 votes
Gopinath Velayudhan June 18, 2012

Were you able to get this working? what change you have to make. I am trying to use the crucible rest API to create review and add changesets.

It would be great if you can provide me with a sample code that is working for you

Thanks

dhandu June 28, 2012

Hi Gopinath, Srry it didn;t work, I am also lookinf for any working rest api working example

0 votes
Renjith Pillai
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.
May 8, 2012

You should be posting to http://localhost:8060/crucible/rest-service/reviews-v1 to create the review. I am not sure what this TEST-1 is added to the URL?

dhandu May 8, 2012

Thanks Renjith,

I tried that also, I removed TEST-1/CreateReview , I got this error

500 Internal Server Error{"code":"JsonMapping","message":"Unrecognized field \"CreateReview\" (Class com.atlassian.fecrurestplugin.crucible.RestReviewService$CreateReview),

Renjith Pillai
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.
May 8, 2012

Do you want to give a local patch or use a change set id for review?

The reason why I asked this is that the patch contents seems to be not valid. See the diff example at

http://docs.atlassian.com/fisheye-crucible/latest/wadl/crucible.html#d2e116

Also in the $body variable, you seem to be repeating the CreateVewi json part again, or am I missing something?

dhandu May 8, 2012

I am trying to add change set, I removed the "patch":"Adding a patch"} as well and tried to generate the review , but receive this error. what is the right syntex of $body for changeset review

500 Internal Server Error{"code":"JsonMapping","message":"Unrecognized field \"CreateReview\" (Class com.atlassian.fecrurestplugin.crucible.RestReviewService$CreateReview),

Thanks

Renjith Pillai
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.
May 9, 2012

Actually you didnt notice the second part of my comment "Also in the $body variable, you seem to be repeating the CreateVewi json part again, or am I missing something?"

AThe error string is reporting that 'CreateReview' is an unknown option, which is true. You are adding that in this line "my $body = '{"CreateReview":{"repository":"TEST","patch":"$data"}}';"

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events