Page 1 of 2

Cannot move document using REST API

Posted: Mon Aug 07, 2017 10:18 am
by phurtado
Hi there.

I'm trying to use the REST API to update de document metadata. With this body I'm successfully changing the document title and some of my extra attribute, but I'm unable to change the folder of the document. I checked that the folderId already exists. Am I forgetting anything?

{"id":3870395,"folderId":3835158,"title":"20170807104422_nx0rv5f4t6_old","attributes":[{"name":"Type","stringValue":"Category 2"}]}

Thanks.

Re: Cannot move document using REST API

Posted: Mon Aug 07, 2017 10:34 am
by agaspa
Hi phurtado,
what version of LD are you testing?

Re: Cannot move document using REST API

Posted: Mon Aug 07, 2017 10:43 am
by phurtado
Hi agaspa.

I'm using v7.6.4

Re: Cannot move document using REST API

Posted: Mon Aug 07, 2017 11:31 am
by admin
Hi you should pay attention to the HTTP method used,
in order to update a document you must use the PUT method.
So in order to change the folder of a document that should be enough

Code: Select all

'{ "id":106758151, "folderId":4 }'
Note that in order to move a document from source folder A to target folder B,
you should have write permission on folder B and delete permission on folder A

Re: Cannot move document using REST API

Posted: Mon Aug 07, 2017 11:59 am
by phurtado
admin wrote:
Mon Aug 07, 2017 11:31 am
Hi you should pay attention to the HTTP method used,
in order to update a document you must use the PUT method.
So in order to change the folder of a document that should be enough

Code: Select all

'{ "id":106758151, "folderId":4 }'
Note that in order to move a document from source folder A to target folder B,
you should have write permission on folder B and delete permission on folder A
Hi admin.

The PUT method is ok and the title and attributes are changing ok. The API user is in the 'admins' group, so I think it's not a permissions problem isn't it?

Re: Cannot move document using REST API

Posted: Mon Aug 07, 2017 1:55 pm
by agaspa
Hi phurtado,
you should carefully check the id of the target folder "folderId"
and perhaps the main log of web-application: /repository/dms.log

Re: Cannot move document using REST API

Posted: Tue Aug 08, 2017 8:01 am
by phurtado
agaspa wrote:
Mon Aug 07, 2017 1:55 pm
Hi phurtado,
you should carefully check the id of the target folder "folderId"
and perhaps the main log of web-application: /repository/dms.log
Hi agaspa.

I'm sure the target folderId is correct. I checked the dms.log but nothing remarkable. Tried adding permissions manually to the admin group on both folders, but nothing changed.

Any other idea? I'm totally lost.

Thanks for your help.

Re: Cannot move document using REST API

Posted: Tue Aug 08, 2017 2:06 pm
by agaspa
Hi phurtado,
in the past it was possible to use the update method also to move a document from one folder to another, but now no longer.
The update method simply modifies the metadata of the document, but does not move it.
The move method has been introduced for this scope, but in the 7.6.4 version is not yet available in the REST API.

Re: Cannot move document using REST API

Posted: Tue Aug 08, 2017 4:06 pm
by agaspa
Try the attached patch (LD 7.6.4)
it adds the method move (HTTP PUT) with 2 query params: docId and folderId

You should uncompress in /classes

on Windows
C:\LogicalDOC\tomcat\webapps\ROOT\WEB-INF\classes

Re: Cannot move document using REST API

Posted: Wed Aug 09, 2017 10:02 am
by phurtado
agaspa wrote:
Tue Aug 08, 2017 4:06 pm
Try the attached patch (LD 7.6.4)
it adds the method move (HTTP PUT) with 2 query params: docId and folderId

You should uncompress in /classes

on Windows
C:\LogicalDOC\tomcat\webapps\ROOT\WEB-INF\classes
Hi agaspa.

I found a bit strange not using json or xml in the put method but this patch worked for me :D :D :D :D

Thank you!