Install Camunda Connect Plugin
Important: In addition to HTTP Connector, the Camunda Connect plugin must also be installed and enabled.
If you get this error:
org.camunda.bpm.engine.ProcessEngineException: ENGINE-09005 Could not parse BPMN process. Errors: One of the attributes ‘class’, ‘delegateExpression’, ‘type’, or ‘expression’ is mandatory on serviceTask. | invokeRestService.bpmn | line 7 | column 75
That’s indeed a badly misleading error message (CAM-4292). To solve it, you need to install the plugin, e.g. in your Spring Boot project’s pom.xml
:
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-connect</artifactId>
</dependency>
Connector’s Input Parameters
Note: Use Connector’s input parameters, not the service task’s input parameters.
url
: String. The URL.method
: String. GET / POST / PUT / PATCH / DELETE.headers
: Map<String, String>
Getting HTTP Response into Connector’s Output Parameters
Note: Use Connector’s output parameters, not the service task’s output parameters.
If you’re sure the response body is less than 4000 characters, you can use:
- Process variable name:
response
- Variable assignment type: String
- Variable assignment value:
${response}
Camunda cannot save string variables larger than 4000 variables, it will throw JDBC error. As alternative, you can either save it as Object/BLOB (see below), or truncate it (reference). To truncate it:
- Variable assignment type: Script
- Script Format:
javascript
- Script Type: Inline Script
- Script:
connector.getVariable("response").substring(0, 4000)
Note: It’s possible to use Java, but it is not friendly (see below). So that’s why Hendy recommends using JavaScript instead.
- Variable assignment value:
${response.length() > 4000 ? response.substring(0, 4000) : response}
How to save Camunda BPM process variable as Object/BLOB?
If the original variable is a freeform string, you can convert it to bytes:
${response.getBytes("UTF8")}
Alternatively, if the original variable is formatted as XML or JSON, then you can convert that to XML or JSON.
Using Java-based expression, with Spin:
${JSON(response)}
${XML(response)}
If using (inline) JavaScript, you have two choices:
S(response)
-> You get Java-style Spin in your JavaScript codeJSON.parse(response)
-> You get native JavaScript object, which Hendy thinks gets converted to Java Map if you return it as process variable