Calling REST services from the process


#1

Hi! I’ve just figured out how to integrate camunda REST API and Webapps into SpringBoot app. My aim is to use this app as a part of my micro-module system. I’m expecting calling this system for starting processes (done by using camunda REST API) but also this system (it’s running processes) calling other our services REST APIs.

We don’t really like the solution from the tutorials with generating those calls as separated projects (java, js,etc.).

I’ve tried to implement smth like this:
image

but getting this error: org.camunda.connect.ConnectorException: No connector found for connector id ‘1’ , 'cause actually don’t understand what id it needs.

The dependencies I’m using:
compile group: ‘org.camunda.bpm.springboot’, name: ‘camunda-bpm-spring-boot-starter-rest’, version: ‘2.3.0’
compile group: “org.camunda.bpm.springboot”, name: “camunda-bpm-spring-boot-starter-webapp”, version: “2.3.0”
compile group: ‘org.camunda.bpm’, name: ‘camunda-engine-plugin-connect’, version: ‘7.8.0’


#2

Found an example for the http connector on the camunda-bpm-example github repo



so the connector Id would be http-connector for rest and soap-http-connector for calling a soap service


#3

This worked, thank you! Now my dependencies for the app are:

compile group: 'org.camunda.bpm.springboot', name: 'camunda-bpm-spring-boot-starter-rest', version: '2.3.0'
compile group: "org.camunda.bpm.springboot", name: "camunda-bpm-spring-boot-starter-webapp", version: "2.3.0"    
compile group: 'org.camunda.bpm', name: 'camunda-engine-plugin-connect', version: '7.8.0'
compile group: 'org.camunda.connect', name: 'camunda-connect-http-client', version: '1.1.2'

Also not sure if I need them, but have:

compile group: 'org.camunda.spin', name: 'camunda-spin-dataformat-json-jackson', version: '1.6.0'    
compile group: 'org.camunda.spin', name: 'camunda-spin-core', version: '1.6.0'

#4

Great tutorial, I could finally call the REST API. The problem is now I’m not able to parse the json response.

Having these additional dependencies:

compile group: 'org.camunda.spin', name: 'camunda-spin-dataformat-json-jackson', version: '1.6.0'    
compile group: 'org.camunda.spin', name: 'camunda-spin-core', version: '1.6.0'

Having this script in the process definition:

S(response).prop("status").value()

Getting this exception when trying to start process:

Cannot instantiate process definition CardUnblock:1:55c99615-301d-11e9-8bfe-267ba38632f7: Unable to evaluate script: ReferenceError: “S” is not defined in at line number 1


#5

I got rid of using S(), instead using:

JSON.parse(response).status

P.S. Got working S() notation by adding

compile group: 'org.camunda.bpm', name: 'camunda-engine-plugin-spin', version: '7.8.0'

into dependencies


#6

@Renata_Akhmetshakiro Is it possible for you to share this module pf calling an external REST API on GitHub?


#7

@harish2624 unfortunately I can’t since it contains some other business logic that is property of the company. But there is really nothing more about camunda than only those dependencies I’ve mentioned above. Then when you run your app on the server you can easily access the REST API of camunda via http://localhost:8080/rest/engine/default/ and camunda web-app just by http://localhost:8080 (it’ll redirect you to the admin page)