How to execute a decision service?

Hi,

Is there any way available to execute decision_service via Rest API or programatically?

I have a decision service definition something like below
image

while calling this decision service I get below response:

But I am able to call the decision table definition, in this case “a”, successfully.

Hi,

You can execute decision services using the Java API using the ExecuteDecisionBuilder. This builder can be obtained via the DmnDecisionService.

You can make use of the executeWithSingleResult() or the executeWithAuditTrail() if you want to execute either a DecisionService or a Decision(Table) with a set key.
Or use explicit methods like executeDecisionService() or executeDecision() to execute either a DecisionService or a DecisionTable.

Currently the REST API exposes only executing decision tables. We will add support for Decision Services in the next release.

Regards,

Yvo

Thank you for the prompt response. Let me try and confirm.

Regards,
Adi

Confirmed. Thank you.

@PostMapping(value = “/executeDecisionServices/{decisionKey}”, consumes = { MediaType.APPLICATION_JSON_VALUE })
public Map<String, Object> executeDecisionServices(@PathVariable(value = “decisionKey”) String decisionKey,
@RequestBody Map<String, Object> variables) {

	return decisionService.executeDecisionServiceWithSingleResult(
			decisionService.createExecuteDecisionBuilder().decisionKey(decisionKey).variables(variables));
}

@PostMapping(value = "/executeDecision/{decisionKey}", consumes = { MediaType.APPLICATION_JSON_VALUE })
public Map<String, Object> executeDecisionTable(@PathVariable(value = "decisionKey") String decisionKey,
		@RequestBody Map<String, Object> variables) {

	return decisionService.executeDecisionWithSingleResult(
			decisionService.createExecuteDecisionBuilder().decisionKey(decisionKey).variables(variables));
}