Menu

#557 restapi - setDocumentAttribute provides error message "Attribute definition not suitable for documents"

6.0.19
open
nobody
REST-API (2)
bug
2023-12-13
2023-12-11
CLM
No

Hi Uwe
first of all, would like to thank you for this great product of yours. I am using SeedDMS since years and it really helps a lot. Kudos to you and your team.
I am using the docker version which you provide on docker hub and version is 6.0.25 and I recently started experimenting with the REST-API because would like to use it in conjunction with automation tools like n8n.
While testing the different functionalities, I wanted to upload a document (which works like a charm) and set my respective custom attributes afterwards.
However, doing so via /document/{id}/attribute/{attrdefid} wasn't working for me. API came always back with "Attribute definition not suitable for documents" and so I was looking into the code and I believe I found a minor defect in line 1584 of /restapi/index.php
Here you go:
/restapi/index.php (6.0.25)
Line 1584:
if($attrdef->getObjType() !== SeedDMS_Core_AttributeDefinition::objtype_document) {

My fix:
if($attrdef->getObjType() != SeedDMS_Core_AttributeDefinition::objtype_document) {

With this small change, I was finally able to modify the attributes of my uploaded documents.
Have a look and let me know what you think.
Thanks,
Christian

Discussion

  • Uwe Steinmann

    Uwe Steinmann - 2023-12-12

    Which database are you using? I'm currently writing a lot of unit tests for the rest api, but this error haven't occured yet.

     
  • CLM

    CLM - 2023-12-12

    I am using MariaDB version 10.3.37

     
  • CLM

    CLM - 2023-12-13

    Hi Uwe
    I looked a bit further and notice the following:
    $attrdef->getObjType() --> returns an integer
    whereas SeedDMS_Core_AttributeDefinition::objtype_document returns a string
    So the comparison operator !== cannot work here because it takes the object type into account which is not the same in the above case.
    Thanks,
    Christian

     
  • Uwe Steinmann

    Uwe Steinmann - 2023-12-13

    I just fixed that and hopefully didn't break anything. The reason why I probably choose a string was sqlite which returns a string for that field in the database. Anyway, using an integer in this case makes a lot mor sense.

     

    Last edit: Uwe Steinmann 2023-12-13
  • CLM

    CLM - 2023-12-13

    Cool - thanks Uwe!
    Appreciate it!

     

Log in to post a comment.