Changing document_type from api [SOLVED]

Anything concerning integration via the REST API
Post Reply
jere
Posts: 8
Joined: Thu Jun 13, 2019 2:02 pm

Changing document_type from api [SOLVED]

Post by jere »

I am trying to change the document type of a document via the API. I *think* I should use the PATCH version of /api/documents/{id}/ but no matter what I put in for document_type, and I've tried several variations, it doesn't work. I see that the front end uses /documents/{id}/type/ but that requires a csrf token that I don't have when using the rest api.

Any pointers in the right direction would be helpful.
elmcrest
Posts: 4
Joined: Tue Sep 03, 2019 8:05 am

Re: Changing document_type from api

Post by elmcrest »

Hey jere,

I'd say it's not possible to change the document_type via an api request. the embedded type for the documents request tells that the document_type id is readOnly ...
besides I would also expect for this kind of operation a dedicated api endpoint so something like /documents/{id}/change_document_type_to/{document_type_id} - just to give you an Idea.

I'm new to MayanEDMS so I might be wrong...

Hope it helped,

cheers
jere
Posts: 8
Joined: Thu Jun 13, 2019 2:02 pm

Re: Changing document_type from api

Post by jere »

My current work around is to connect to the database directly and manipulate it there. I'm sure this is bad and I hope to be able to use the API in the future. I'm not sure *how* it is bad other than any indexes relying on the doc type have to be rebuilt afterwards.
User avatar
rosarior
Developer
Developer
Posts: 582
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Changing document_type from api

Post by rosarior »

Thanks for the feedback, we'll add an API entrypoint to change the document type of a document.
mcrotsenburg
Posts: 4
Joined: Wed Sep 11, 2019 6:56 pm

Re: Changing document_type from api

Post by mcrotsenburg »

rosarior wrote: Fri Sep 06, 2019 9:40 pm Thanks for the feedback, we'll add an API entrypoint to change the document type of a document.
Is there a timeline for this feature request? I just discovered that I require the same functionality. Thanks!
User avatar
rosarior
Developer
Developer
Posts: 582
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Changing document_type from api

Post by rosarior »

We are going to try to squeeze this for the version 3.3 release. This release is scheduled for October after bugfix version 3.2.8 is out.
mcrotsenburg
Posts: 4
Joined: Wed Sep 11, 2019 6:56 pm

Re: Changing document_type from api

Post by mcrotsenburg »

Awesome. You are a gentleman and a scholar!
User avatar
rosarior
Developer
Developer
Posts: 582
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Changing document_type from api

Post by rosarior »

Document type change API is now in the version 3.3 code: https://gitlab.com/mayan-edms/mayan-edm ... 85e46c8cb1. This version is almost ready.
Post Reply