Does Rest API support the function to upload a document to exiting item as a new version? What's the correct structure to make the call?
Thanks.
Hi,
Yes, you should be able to do this like so:POST: Your_Content_Server/otcs/cs.exe/api/v1/nodes/12345/versionsWhere 12345 is the NodeID of the item you wish to add a version to.
You just need to attach in your form-data payload a "file" which can be done through various file libraries. If you're testing in something like PostMan, you can click on the field type in "KEY" and select file instead of text, letting you pick a file off disk.
Then just submit it, and you'll see a new version was added. (Make sure you have a valid OTCSTICKET in your header)
If you want to see for yourself what various actions may need to formatted as, I suggest you run something like Fiddler, and perform the same action in the SmartUI. The POST/PUT/DELETE/etc. should give you something to run with when you're writing your application.
If you're writing an application in Java, I found the Apache httpClient very easy to write something useful in.
Thanks,
Nizar
Thank you for the guide. I am using Javascript, below code works for me.
var file = $('#file')[0].files[0]; var body = { id: 238006053 }; formData = new FormData(); formData.append('body', JSON.stringify(body)); formData.append('file', file); $.ajax({ type: 'POST', url: cgipath + '/api/v1/nodes/238006053/versions', data: formData, processData: false, contentType: false, headers: { otcsticket: otcsticket }, success: function(data) { console.log('success: ', data); }, error: function(request, status, error) { console.log(status + ': ' + request.responseText); } });
any update on this issue