Upload Document to DocuWare from Mendix with Rest API

0
Hi, I’m attempting to configure a Microflow to take a file in Mendix and upload it to our DocuWare system while also adding the field values (file name, client, etc.) to the DocuWare data entry. I’ve referenced the DocuWare API documentation and have successfully used Postman to send files and index values, but I’m unable to recreate this API call in a Microflow. Is there any documentation specifically for interacting with the DocuWare API in Mendix? Thank you, Dan
asked
2 answers
0

Quickly scanning the documentation it seems that the part of the json message contains this:

file: { value: chunk,

the ‘chunk’ should be a base64encoded representation of the document. So create an unlimited attribute ‘chunk’ for that data. Before calling the API call the community commons StringFromFile and then Base64Encode, put the value in chunk, map that attribute, call the API and clear the field (preventing unneeded database growth), or use NP objects.

 

 

answered
0

Thank you for the response, Chris. I like the idea of using a non-persistable entity to keep the Mendix database small.

I ended up using two different API calls to accomplish the upload of the file to DocuWare and the update of the index/attribute values of the DocuWare record.

  • First API call to upload the document to DocuWare
    • DocuWare endpoint: {{ServerUrl}}/{{Platform}}/FileCabinets/{{FileCabinetId}}/Documents
    • Request: Binary option, with the Mendix file contents as the Contents
    • Receive JSON back, which is mapped to an Response entity to grab the DocuWare Document ID
  • Second API call to update the index/attribute values
    • DocuWare endpoint: {{ServerUrl}}/{{Platform}}/FileCabinets/{{FileCabinetId}}/Documents/{{DocumentId}}/Fields
    • Request: Custom request template, using parameters to dynamically set values


There’s probably a better way to do this, but I couldn’t get the JSON that the DocuWare API wants properly mapped in Mendix.  The JSON template represents the actual field names and values in attributes instead of key/value pairs so the Mendix JSON interpreter just showed a bunch of FieldName objects.
 

{
    "Field":[ 
        { "FieldName":"COMPANY", "Item": "Company 1", "ItemElementName":"String"},
        { "FieldName":"CONTACT", "Item": "Company 2", "ItemElementName":"String"}
    ]
}


Thanks again,
Dan

answered