Updating a document via Restful API or database

We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
rdovell
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Wed Apr 06, 2016 6:10 pm

Updating a document via Restful API or database

Post by rdovell » Wed Mar 22, 2017 4:50 pm

I am working on importing a large number of documents from another document management solution, some of these documents have a few versions that need to be preserved.

Using the restful API, I am able to upload a document but receive an ItemExistsException when trying to upload a different document with the same save path. Is there a way that I can add a new version of a document over an existing one using the Restful API?

rdovell
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Wed Apr 06, 2016 6:10 pm

Re: Updating a document via Restful API or database

Post by rdovell » Wed Mar 22, 2017 5:37 pm

I figured it out, here are the relevant curl commands for someone else:

You need to checkout the document, then check it back in which increments the version number by 0.1

Checkout command:
curl -u okmAdmin:admin -H "Accept: application/json" http://localhost:8080/OpenKM/services/r ... 4e780fae3a

Checkin command(If you have a file in the local directory called 'foobar.txt'
curl -u okmAdmin:admin -H "Accept: application/json" -X POST -F docId="afc7b0cd-d0ab-4920-8b5d-d64e780fae3a" -F content=@foobar.txt http://localhost:8080/OpenKM/services/r ... nt/checkin

jllort
Moderator
Moderator
Posts: 10717
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Updating a document via Restful API or database

Post by jllort » Thu Mar 23, 2017 9:25 pm

If you wait for the next week we will release a migration tool what can be extended for this purpose.

Post Reply