Mayan RESTAPi

Hi @roberto.rosario I have gone through the endpoint, however I don’t know if you can include in the knowledge base how to upload document using the API.

More so I have gone through the api and database structure, looking at the POST method request for the “http://192.168.100.36/api/v4/documents/upload/” because I’m confused seeing “document_id integer NOT NULL,” in the database and the ““document_type”: {
“delete_time_period”: 30,
“delete_time_unit”: “days”,
“document_stub_expiration_interval”: 86400,
“document_stub_pruning_enabled”: true,
“filename_generator_backend”: “uuid”,
“filename_generator_backend_arguments”: “”,
“label”: “document_type”
},” in the documentation.

You need to create the document first before you upload it. It is documented here:

https://docs.mayan-edms.com/apps/rest_api/index.html

1 Like

Thanks for your response
You mean create the document and upload document will be in request?

However how those multiple files be uploaded via the API as it’s in the mayan front end?

Regards

I’m not quite sure that I really understood your question but in general to upload a file you first create a new document with the first api request. You will get a document id that you can use to upload your document file in the second request.

I’m not sure what you mean by that?!

Thanks that exactly what I was saying.

But then then the request body to create
“{
“description”: “string”,
“document_type”: {
“delete_time_period”: 2147483647,
“delete_time_unit”: “days”,
“document_stub_expiration_interval”: 9223372036854776000,
“document_stub_pruning_enabled”: true,
“filename_generator_backend”: “string”,
“filename_generator_backend_arguments”: “string”,
“label”: “string”,
“trash_time_period”: 2147483647,
“trash_time_unit”: “days”
},
“file_latest”: {
“comment”: “string”,
“filename”: “string”,
“pages_first”: {}
},
“label”: “string”,
“language”: “string”,
“version_active”: {
“active”: true,
“comment”: “string”,
“pages_first”: {
“content_type”: {},
“content_type_id”: 0,
“object_id”: 2147483647,
“page_number”: 2147483647
}
}
}”
is the same as the request body for the upload document which is as below
{
“description”: “string”,
“document_type”: {
“delete_time_period”: 2147483647,
“delete_time_unit”: “days”,
“document_stub_expiration_interval”: 9223372036854776000,
“document_stub_pruning_enabled”: true,
“filename_generator_backend”: “string”,
“filename_generator_backend_arguments”: “string”,
“label”: “string”,
“trash_time_period”: 2147483647,
“trash_time_unit”: “days”
},
“label”: “string”,
“language”: “string”,
“file_latest”: {
“comment”: “string”,
“filename”: “string”,
“pages_first”: {}
},
“version_active”: {
“active”: true,
“comment”: “string”,
“pages_first”: {
“content_type”: {},
“content_type_id”: 0,
“object_id”: 2147483647,
“page_number”: 2147483647
}
}
}

If you could put me through on the exact payload to use in other to create a document.

The last question : How do I use the same endpoints to upload multiple files?

Thanks once again for your response.

For now I’m not on my computer and I cannot give you any details while I’m on the phone. You may want to have a look at this piece of source code from one of my projects:

Document is created in line 225 and document upload follows after that. It’s a bit hard to read because the Rest API is a bit hidden in the mayan.py file but it might give you an idea. It is not the same payload and not the same endpoint of course.

This topic was automatically closed 8 hours after the last reply. New replies are no longer allowed.