REST API Upload document to a cabinet

Anything concerning integration via the REST API
Post Reply
EdVonSchleck
Posts: 4
Joined: Tue Sep 17, 2019 7:33 am

REST API Upload document to a cabinet

Post by EdVonSchleck »

Sorry to ask again, this time as a new thread.
Maybe this time this question gets some attention.

I am trying to migrate a few thousend documents from another DMS to Mayan using the API.
All documents have tags and are organized in folders and sub-folders. The requirement ist to resemble the fodler structure in Mayan.
Luckily, there are cabinets. I can add cabinets to form a hierarchy.
However, I on my part had no luck so far getting documents in any of the cabinets.

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

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

Re: REST API Upload document to a cabinet

Post by rosarior »

I just tried it our and works as expected with version 3.3.12.

The result code should be 201.

it could be a permission issue, try it out on the UI with the same API user to validate it is correctly setup. The "Add documents to cabinets" permission must be granted for the cabinet and the document/document type.
2020-02-12_22-52.png
2020-02-12_22-52.png (44.66 KiB) Viewed 28 times
2020-02-12_22-52_1.png
2020-02-12_22-52_1.png (87.98 KiB) Viewed 28 times

Post Reply