How to upload a file (org.jbpm.document.Document) when starting processs in Intelligent Process Server by using Rest API in BPM Suite 6?

Solution Verified - Updated -

Environment

Red Hat JBoss BPM Suite (BPM Suite) 6.3.x, 6.4.x

Issue

Is there a way to upload a file (org.jbpm.document.Document) when starting process using Kie-server Rest APIs?

Resolution

To manage document as process variable by kie-server Remote REST API, Deployment Descriptors (kie-deployment-descriptor.xml) needs to be configured properly. It can be edited via the Business Central following the next steps:

  1. In the Business Central, go to Authoring -> Project Authoring;
  2. Open Project Editor from your project in the Project Explorer;
  3. At first, select Deployments -> Deployment descriptor in the dropdown menu in the project general settings;
  4. Go down to Marshalling strategies and add the following values:

    Value: org.jbpm.document.marshalling.DocumentMarshallingStrategy
    Resolver type: reflection
    
  5. Then, go down to Remoteable classes and add the following value:

     Value: "org.jbpm.document.service.impl.DocumentImpl"
    
  6. Now, click on the Save button;

  7. Click onOpen Project Editor from the Project Explorer and then click on the Save button;
  8. Next, click on the Build -> Build & Deploy button. Be sure that you do not have process instances alive;
  9. Finally, copy jbpm-document-6.4.0.Final-redhat-x.jar from business-central.war/WEB-INF/lib to kie-server.war/WEB-INF/lib and then restart it.

Here is an example of REST request which pass the document as a process variable named 'document'.

Rest END point (POST):
http://server:port/kie-server/services/rest/server/containers/{containerName}/processes/{processId}/instances
Request Headers:
authorization: Basic xxxxx
accept: application/json
content-type: application/json
x-kie-contenttype: JSON
Request Body (i..e doc.json):
{"document" : {
        "org.jbpm.document.service.impl.DocumentImpl":{
            "identifier":"XXXXX",
            "name":"name.ext",
            "link":"XXX",
            "size": "nnn",
            "lastModified":,
            "content":"BASE64 content"
        }
    }
}

Here is a full CURL command as sample:

curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kie_server_user:kie_server_password' -d @doc.json 'http://localhost:8080/kie-server/services/rest/server/containers/{container_id}/processes/{process_id}/instances'

Note: The document content needs to be base64 encoded when it gets passed as value of content.

Root Cause

Document support was not added in 6.3 or 6.4.x to kie server yet.
To achieve basic support, need to follow the steps described in Resolution above.

Here is useful information about the improved support in kie server for documents that comes with version 7:
KIE Server (jBPM extension) brings document support

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments