Interact with your Bonita process
Interact with a Bonita runtime in multiple ways using API requests.
Prerequisites
-
Bonita UI Builder downloaded and launched
-
Bonita Studio version 2024.3 or any later version
-
A running Bonita project with a defined process diagram, BDM, and contract. Follow the Getting Started tutorial if you need any help
Interact with Bonita API
You can interact with the Bonita runtime using the REST APIs through the default "Bonita API" datasource.
Create Bonita API requests
You can create API requests and interact with the Bonita runtime with the REST APIs. We will describe below how you can, for example, get a list of Bonita processes, and instantiate one of them.
Get a list of processes
To get the list of the processes deployed on the Bonita runtime (first 10): click the Editor
icon from the left panel, click the Queries
tab, then click the new query / API
button and select the Bonita datasource created previously.
Enter the following configuration:
-
Method
: GET -
URL
: /bonita/API/bpm/process -
Params
:-
Key
: p -
Value
: 0 -
Key
: c -
Value
: 10
-
Then, click on Run
to test the API and see the result in the Response
tab.
The authentication to the Bonita runtime is automatically handled by the Bonita datasource. |
Then, you can use the Table
widget to display the list of the processes in your application.
Instantiate a process
Now, we will instantiate one of the processes with what the user typed in the form we created previously.
Click the Editor
icon from the left panel, click the Queries
tab, then click the new query / API
button and select the Bonita datasource created previously.
Enter the following configuration:
-
Name
: instantiateProcess -
Method
: POST -
URL
: /bonita/API/bpm/process/{{getProcess.data[0].id}}/instantiation -
Body
:
{{ { claimInput: { description: Input1.text } } }}
This API will instantiate the first process returned by getProcess
with the body
's content.
In Bonita, you need to refer to your contract in order to instantiate a process.
Here, we used the contract defined in the Getting Started tutorial as an example: |
Now, we need to tell the form to execute this API request after clicking the submit
button.
Go to the UI
tab and click the form’s submit
button. On the right panel, click the onclick
label, then select execute a query
and choose instantiateProcess
:
Everything is settled. Now, click the preview
button on top of the screen and test your form:
You now have a working interface that interacts with your Bonita process and data, congratulations!