Using the Crucible API to add files to a review

I'm writing a script to pull changed files from Perforce and add them to a review in Crucible. I've looked at the API docs, but for the addFile call, the docs don't specify what the content (XML) of the request should look like. For instance, in the addChangeset call (which I have used), the docs specify that the XML request uses an <addChangeset> block, with a <changesets> and then <changesetData> nodes for each changeset. I don't see anything giving that level of detail for the addFile call. Can someone provide more detail on the required XML content for an addFile call? Thanks.

p.s., this is the documentation I've been looking at: http://docs.atlassian.com/fisheye-crucible/latest/wadl/crucible.html#d2e2178

1 answer

This widget could not be displayed.

The documentation mentions that this call does't expect an XML document with embedded files.
Instead it uses multipart form data encoding to receive the file.

Using cURL it looks like this:

curl --user rene:password -F file="@killerapp.cpp" -X POST http://localhost:8060/rest-service/reviews-v1/CR-123/addFile

Sorry it took me so long to get back to this. Your answer was helpful. What I would like to do is add 2 versions of the same file to a review (like a fromPath and toPath). It seems that, to do this, I would need the 2 files on a local file system, from which I could upload them to Crucible via the HTTP request. I guess I was looking for a way to do that from my source control system (perforce) rather than from my local file system. I know I can use the Crucible UI, but I wanted to automate it.

Using the cURL command I got the following error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error><code>IllegalArgument</code><message>fileToReview cannot be be null</message></error>

I had gotten the same error while trying to test the API using Postman.

How could this be resolved?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 18 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

45 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you