How to upload a file (org.jbpm.document.Document) when starting processs in Intelligent Process Server by using Rest API in BPM Suite 6?
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:
- In the Business Central, go to
Authoring -> Project Authoring
; Open Project Editor
from your project in theProject Explorer
;- At first, select
Deployments -> Deployment descriptor
in the dropdown menu in the project general settings; -
Go down to
Marshalling strategies
and add the following values:Value: org.jbpm.document.marshalling.DocumentMarshallingStrategy Resolver type: reflection
-
Then, go down to
Remoteable classes
and add the following value:Value: "org.jbpm.document.service.impl.DocumentImpl"
-
Now, click on the
Save
button; - Click on
Open Project Editor
from theProject Explorer
and then click on theSave
button; - Next, click on the
Build -> Build & Deploy
button. Be sure that you do not have process instances alive; - Finally, copy
jbpm-document-6.4.0.Final-redhat-x.jar
frombusiness-central.war/WEB-INF/lib
tokie-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