Search code examples
drools

Can we update/delete facts in a Drools rule engine via REST requests?


Can we update/delete facts in a Drools rule engine via REST requests? I searched on this a lot and went through the drools documentation. But I could only find the insert operation via REST POST request and I could successfully do it. I want to execute something like below. I tried both POST and PUT with below. They did not work. Purpose is to update/delete a fact already in drools engine and re-execute the rules.

URL: http://localhost:8080/kie-server/services/rest/server/containers/instances/DroolsDemo2_1.0.0

Request Body:

{
  "commands": [ {
      "modify": {
        "fact-handle": "000.123.321",
        "setters": {
            "accessor": "approved",
            "value": "true"
        }
      }
    },
    {
      "fire-all-rules": {
        "max": 10,
        "out-identifier": "firedActivations"
      }
    },
    {
      "get-objects": {
        "out-identifier": "objects"
      }
    }
  ]
}

Solution

  • Yes you can do that. I am not sure about the exact format, however this part of documentation might help you: https://docs.jboss.org/drools/release/7.17.0.Final/drools-docs/html_single/index.html#_ch.commands.