danmunn / redmine_dmsf

Fork of svn repository for redmine_dmsf
GNU General Public License v2.0
423 stars 194 forks source link

Revision API issues #1564

Open EdoardoBini opened 3 days ago

EdoardoBini commented 3 days ago

Hello all,

I'm trying to use the Revision API, as shown in the documentation, but i'm encountering some issues. Using the following endpoint: /dmsf/files//revision/create.json i created the following body:

 {
    "dmsf_file_revision":{
        "title": "Prova-0002.pdf",
        "name": "Prova",
        "description": "test",
    },
    "version_major": 2,
    "version_minor": 0,
    "version_patch": 0
    "dmsf_attachments":[
        {
            "filename": "Prova-0002.pdf",
            "token": "12509.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
        }
    ]
}

As showed, i first created a token with my file to insert and then i tried to do the post. From the endpoint, i received the following response:

500 Internal Server Error If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

If i use a form-data, with the same endpoint and adapting the body, i received 200 OK from the endpoint, but the API seems not doing anything, in fact i received the id of the previous revision and not the new one. I have also tried the xml version but i have the same behaviour. If i remove the .json or .xml from the request, i receive a 422 status code. My question is:

How's the correct way to do this type of request, without using the create token and commit APIs?

Because i need to change the metadata of the file, and not using the same name as suggested from the documentation. Thanks in advance for the answer.

picman commented 3 days ago

Do I understand right, that your intention is to create a new document's revision without uploading new content? What "metadata" you want to change?

EdoardoBini commented 3 days ago

I am not probably understanding well the create revision API. Anyway, i would be interested in doing both things:

My problem, so far, is that i do not understand from the guide how to do that. Moreover, when i try to copypaste the example in the guide from documentation, the response i receive is 500 and if i try to adapt the body (similar to easy redmine gui behaviour) i get 200 ok but no new revision appears (indeed it returns the last valid revision id and not the new one)

Thank you in advance for the help.

picman commented 3 days ago

Take a look here: https://github.com/danmunn/redmine_dmsf/blob/master/extra/api/api_client.sh Focus on 3. Upload a new document and 4. Create a new revision. In the same folder are located corresponding XML files.

EdoardoBini commented 3 days ago

I have already tried but maybe i'm missing something... i put it easier. Let's say i have uploaded and committed successfully the first version of a document (section 3). Now i want to upload, as a revision, a newer version of the document with updated filename, title and metadata. How do i do it? If i use again point 3, i can upgrade the version of the file, but i cannot change the title and filename. If i use point 4 it seems not working, i received 200 ok, no changes are applied. The same operation is perfectly working if i use the easy redmine gui.

picman commented 3 days ago

So, you have a document, let's say

#456 | My document | analysis.pdf | 0.1

And you want to update it to

#456 | Another document | itirenary.odt | 0.2

So at the end of the day we will have one document with two revisions each with a different name, file and other properties too?

EdoardoBini commented 3 days ago

Yes exactly. How should i use the apis in order to achieve the task?

picman commented 2 days ago

Something like that is not possible at the moment. When creating a new revision, the document to be updated is identified by the file name. So you can upload a new content but the file name must be kept. Thank to your issue I found that also updating of custom field values don't work any more. I had to modify the specification and the code as well.

https://github.com/danmunn/redmine_dmsf/wiki/REST-API#3-upload-a-document-into-a-given-folder-or-the-root-folder