Re: Problem with /api/documents/{id}/versions/ [SOLVED]
Re: Problem with /api/documents/{id}/versions/ [SOLVED]
Thanks for the report. The issue has been added to the queue to diagnose and fix.
Re: Problem with /api/documents/{id}/versions/
I was unable to replicate the error. The API worked as expected.
Here are some issues with your code sample:
the URL must be in the form: "http://<your IP address>/api/documents/<actual ID of the document>/versions/"
Example:
If you have a Mayan install at 192.168.1.1 that contains a document with an ID of 5 the URL would be:
"http://192.168.1.1/api/documents/5/versions/"
The other issue is that the json argument is for requests that return data, to send data use the 'data' argument like so:
Give this a try and let us know it works or there are other issues. Thanks!
Here are some issues with your code sample:
Code: Select all
with open(pdf, mode='rb') as file_object:
requests.post('*/api/documents/{id}/versions/',auth=('admin','password'),files={'file':file_object},json={'comment':'new-upload'})
Example:
If you have a Mayan install at 192.168.1.1 that contains a document with an ID of 5 the URL would be:
"http://192.168.1.1/api/documents/5/versions/"
The other issue is that the json argument is for requests that return data, to send data use the 'data' argument like so:
Code: Select all
with open(pdf, mode='rb') as file_object:
requests.post('http://192.168.1.1/api/documents/5/versions/', auth=('admin', 'password'), files={'file': file_object}, data={'comment': 'new upload'})
Re: Problem with /api/documents/{id}/versions/
Here is the documentation chapter covering API usage with additional examples: https://docs.mayan-edms.com/topics/integration.html
Re: Problem with /api/documents/{id}/versions/
Hi! I'm trying to do the same thing and I'm having problems with the part. Can you bring me an example of the file_object value?
Thanks!
Lucas.
Code: Select all
files={'file': file_object}
Thanks!
Lucas.
Re: Problem with /api/documents/{id}/versions/
The example has been fixed: https://docs.mayan-edms.com/topics/integration.html
It reads now:
It reads now:
Code: Select all
with open('test_document.pdf', mode='rb') as file_object:
requests.post('http://127.0.0.1:8000/api/documents/', auth=('username', 'password'), files={'file': file_object}, data={'document_type': 1}).json()
{u'description': u'',
u'document_type': 1,
u'id': 19,
u'label': u'test_document.pdf',
u'language': u'eng'}