REST API Integration for Drools Workbench Rules

Priyal Vyas
3 min readApr 11, 2024

--

In the previous article (Setup for drool workbench ), we successfully set up the Drool Workbench. In this article, we will look at how to invoke a rule using the rest API.

Please ensure that kie-server has been deployed(check the deploy section in the Drool Workbench).

Default-kie-server

We cannot access the content directly because it requires authorization. Please specify the username and password of the application user for all API calls.

Username-Password for Basic Auth

To get information about our remote server, send a “Get” request to this URL.

Remote server info

Here, I’ll use a sample project from Drool Workbench.

Click On Myspace -> Try Samples -> Traffic violation Project

The user can create their own project and then build it (there should be no errors; otherwise, build and deploy will fail).
To execute it from rest, we must first deploy it to our remote server.
Click on build and then deploy, as seen below.

Once build and deploy are successful, the user can check the deployment in the deploy section.

To get information on all the containers that are deployed, hit the following URL:

http://localhost:8080/kie-server/services/rest/server/containers

Now that we have container-id (“traffic-violation_1.0.0-SNAPSHOT”) from the above URL, we can use this to get details.

In our sample project, we have dmn. The below URL will give us all the dmn model details for our project.

http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn

Now to run dmn model , regardless of the request format (json /xml) , the request requires the following elements (refer to the above response):

  • Model namespace
  • Model name
  • context object containing input values.

Post request to run the model :- http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn

Body:-

Output:-

We successfully executed our model through a Rest API call. Refer to the official documents of Red Hat for other model’s URL requests or responses.

In the next article, we will understand the DMN model in depth.

--

--