Document version Export API missing?

I need to export the active version of a document using API but it seems to me no possibile because a cannot identify any “version_url” for downloading a PDF file.
The most suitable V4 API is: /documents/{document_id}/versions/{document_version_id}/export/ but the only result is to have a new document in download area and no way to download it programmatically.

I would expect to have in the API response at least an url to use for downloading. Instead I’m receiving only status code 202 Accepted

Can anybody tell me how is possible to do ?


This is not possible because the export is submitted as a background task to be processed at an undetermined time in the future. This is why the endpoint return a 202 code. This is the same issue if you want a document ID when uploading documents via the staging folder REST API. Any REST API that triggers a background task will have this issue as it cannot return you any information because no action or database modification has yet taken place.

The HyperText Transfer Protocol (HTTP) 202 Accepted response status code indicates that the request has been accepted for processing, but the processing has not been completed; in fact, processing may not have started yet. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.

202 is non-committal, meaning that there is no way for the HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing.

The only solution that covers all use cases in Mayan that we’ve discussed, are runtime REST API webhooks for Celery tasks to notify you when the task completes. So far we’ve not seen any library implementing exactly this and the few existing regular webhook libraries for Django are not a good match for our purpose. The only course of action will be to once again roll out our custom implementation, and that will take some time.

Thanks for reply.
I understand your point of view and Mayan architecture but do you think is possible ( as workaround) to have an API that exposes the download area files queue where is possible to obtain the “document name” and the the “version time stamp” (both information are known from the previous api calls to obtain the active version id) and the download url (as final result), I could launch the export process API (return code 202) and wait for the result in the download area using that new download area API (looking for version time stamp and document name) and maybe delete the file once my download process has been terminated?


Yes definitely. The goal is to have these and all models/interfaces exposed over the REST API too. I’ve added the file downloads area API for inclusion in version 4.5 as schedule allows.

API for the downloads was included in version 4.5. Please give it a try.

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