upload document with specified cabinet/tag!

Anything concerning integration via the REST API
Post Reply
bixmatech
Posts: 9
Joined: Tue Nov 26, 2019 6:35 pm

upload document with specified cabinet/tag!

Post by bixmatech »

Hello,
any idea how to upload document to a specific cabinet with specifying the tags?
example:
i want to upload document1.jpg to cabinet3 with tags: tag6,tag8.

User avatar
rosarior
Developer
Developer
Posts: 494
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: upload document with specified cabinet/tag!

Post by rosarior »

Hi,

It is not possible to upload a document while also adding to a cabinet and adding a tag. These operations must be done separately.

First, upload the document via the API as outlined here: https://docs.mayan-edms.com/chapters/rest_api.html
Then using the ID returned in the previous response, do two more requests: one to the tags API and the other to the cabinets API.

bixmatech
Posts: 9
Joined: Tue Nov 26, 2019 6:35 pm

Re: upload document with specified cabinet/tag!

Post by bixmatech »

Thanks, solved

EdVonSchleck
Posts: 4
Joined: Tue Sep 17, 2019 7:33 am

Re: upload document with specified cabinet/tag!

Post by EdVonSchleck »

Hi Bixmatech,

could you please add some code how you finally added the document to a cabinet?

I on my part had no luck so far. I tried python:

Code: Select all

res=this.Session.post(this.Url+"/cabinets/"+str(parentId)+"/documents/",data={"documents_pk_list":str(docId)}).json()
where parentId is a valid id of a cabinet and docId is the id returned when adding it to mayan.
However, the function returns ok but no document is added

Alternatively, I tried curl:

Code: Select all

curl -u admin:pass -X POST "http://127.0.0.1:8000/api/cabinets/11/documents/" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"documents_pk_list\":\"116\"}"
No response but also no document in the cabinet.

Any hints?

Thank you,
Ed

(I posted this question also in another thread, but that got no attention. Sorry, if this is considered a dupe)

Post Reply