I downloaded and started the Camunda Community Platform. Now I building a simple workflow that needs to call a web API over HTTP(s) (a simple post and forget for the start). Can someone tell me if there is a way to do this out of the box using a script? Or do I need to install additional Java packages, Camunda exctension, etc.?
Until today I only build some workflows, deployed them on an existing Camunda instance and accessed them via web API in C# and Java Script. So I don’t have any experience what is required on the Camunda server or what is not. I only used simple JavaScript code in BPMN to access variables of workflow etc.
So I would be thankful, if some could tell me if there is a out-of-the box way to access a web API from inside BPMN or point me to an easy guide how to accomplish.
Thank you for your advice. You helped me. I got it working and luckily without having to learn Maven, JAVA, POM, BOM, and other XML config, whatever stuff
Here is a short how-to for non Java developers:
Q: Is there a build in way to access a web-API after downloading the Camunda Platform?
Yes, you can use the connector architecture out of the box.
Q: How to access a Http web API?
Start the Camunda Community Platform (runs on localhost:8080 )
Download the BPMN file from the examples repository and open it in the Camunda Modeler
Click on Check if date is holiday => Configure Connector => isHoliday : Script and change Script Type to Inline Script
Paste the content of the parseHoliday.js file from example repository into the Script field
Deploy the BPMN to Camunda (e.g. use the corresponding button in the Camunda Modeler toolbar)
Goto the Camunda Tasklist. Click on Start process. Select Get Hoilday. Add a variable named date variable of type Date like 2020-05-01T22:22:22 and hit Start
I used HTTP. Not yet sure if web API access will also work via HTTPS.
In my case the task list doesn’t work in Microsoft Edge, only in Firefox or Chrome.
The default user name and password is demo/demo.
It helped a lot to read Get started with Camunda as a refresher.
Q: How to add results from the web-API to variables of the workflow?
1st: the result of your Jacacript code will be put in the variable that is defined in the Output Parameter => Name field.
2nd: you can access the execution object to set other variables of the workflow (like in my example JavaScript code)
var response = connector.getVariable("response");
// in this case the return value is a simple string
var myResult = JSON.parse(response);
// set a variable in the workflow
var execution = connector.getParentVariableScope();
execution.setVariable("result", myResult);
// this will be the value of the Output Paramter (isHoliday in the example)
false