Cannot move document using REST API

Do you want to create a native client or integrate with third party applications: webservices are the solution.

Moderator: car031

phurtado
Posts: 6
Joined: Mon Aug 07, 2017 10:08 am

Cannot move document using REST API

Post by phurtado » Mon Aug 07, 2017 10:18 am

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.

agaspa
Posts: 514
Joined: Tue Apr 20, 2010 8:24 am

Re: Cannot move document using REST API

Post by agaspa » Mon Aug 07, 2017 10:34 am

Hi phurtado,
what version of LD are you testing?

phurtado
Posts: 6
Joined: Mon Aug 07, 2017 10:08 am

Re: Cannot move document using REST API

Post by phurtado » Mon Aug 07, 2017 10:43 am

Hi agaspa.

I'm using v7.6.4

admin
Site Admin
Posts: 10
Joined: Mon Apr 19, 2010 2:20 pm

Re: Cannot move document using REST API

Post by admin » 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

phurtado
Posts: 6
Joined: Mon Aug 07, 2017 10:08 am

Re: Cannot move document using REST API

Post by phurtado » Mon Aug 07, 2017 11:59 am

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?

agaspa
Posts: 514
Joined: Tue Apr 20, 2010 8:24 am

Re: Cannot move document using REST API

Post by agaspa » 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

phurtado
Posts: 6
Joined: Mon Aug 07, 2017 10:08 am

Re: Cannot move document using REST API

Post by phurtado » Tue Aug 08, 2017 8:01 am

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.

agaspa
Posts: 514
Joined: Tue Apr 20, 2010 8:24 am

Re: Cannot move document using REST API

Post by agaspa » Tue Aug 08, 2017 2:06 pm

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.

agaspa
Posts: 514
Joined: Tue Apr 20, 2010 8:24 am

Re: Cannot move document using REST API

Post by agaspa » 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
Attachments
LD-764-patch-REST-move.zip
(7.49 KiB) Downloaded 156 times

phurtado
Posts: 6
Joined: Mon Aug 07, 2017 10:08 am

Re: Cannot move document using REST API

Post by phurtado » Wed Aug 09, 2017 10:02 am

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!

Locked

Who is online

Users browsing this forum: No registered users and 1 guest