Calling decision services
Your client application calls an endpoint through the decision runtime REST API to execute a decision service. The client calls the decision service by using the standard HTTP GET and POST commands that the web browsers use when they interact with remote servers.
A client application calls a decision service by creating a secure connection with a server, and then calling the decision service through the REST API.
Endpoint to execute with a decision ID (decisionId)
POST https://<server>:<port>/ads/runtime/api/v1/deploymentSpaces/{deploymentSpaceId}/decisions/{decisionId}/operations/{operation}/extendedExecuteFor more information about the exact URL patterns for calling decision services, see Runtime REST API reference.
- <server> is the hostname of the decision runtime, which is specified in the decision_runtime.ingress.hostname parameter.
- <port> is the port of the decision runtime.
| Parameter | Mandatory or Optional | Description |
|---|---|---|
| deploymentSpaceId | Mandatory | URL encoded identifier that uniquely identifies the place where a decision was deployed. |
| decisionId | Mandatory |
URL encoded identifier that uniquely identifies a decision to execute. |
| operation | Mandatory |
Name of the operation. It is used to identify which decision service to execute within the decision service archive. The operation name is decided at authoring time. |
Endpoint to execute the last sorted version of a decision service
POST https://<server>:<port>/ads/runtime/api/v1/selectors/lastSortedDecisionServiceVersion/deploymentSpaces/{deploymentSpaceId}/operations/{operation}/extendedExecute?decisionServiceId={decisionServiceId}The version of a decision service refers to the decisionServiceVersion metadata
of the decision service. For more information about the metadata, see Decision service metadata.
- <server> is the hostname of the decision runtime, which is specified in the decision_runtime.ingress.hostname parameter.
- <port> is the port of the decision runtime.
| Parameter | Mandatory or Optional | Description |
|---|---|---|
| deploymentSpaceId | Mandatory | URL encoded identifier that uniquely identifies the place where a decision was deployed. |
| operation | Mandatory |
Name of the operation. It is used to identify which decision service to execute within the decision service archive. The operation name is decided at authoring time. |
| decisionServiceId | Mandatory |
Query parameter that identifies the decision project from which the decision service archive is built. The decision service ID is decided at authoring time. Its value is that of the
|
Endpoint to execute the last deployed version of a decision service
POST https://<server>:<port>/ads/runtime/api/v1/selectors/lastDeployedDecisionService/deploymentSpaces/{deploymentSpaceId}/operations/{operation}/extendedExecute?decisionServiceId={decisionServiceId}The deployment time of a decision service refers to the deploymentTime metadata
of the decision service. For more information about the metadata, see Decision service metadata.
- <server> is the hostname of the decision runtime, which is specified in the decision_runtime.ingress.hostname parameter.
- <port> is the port of the decision runtime.
| Parameter | Mandatory or Optional | Description |
|---|---|---|
| deploymentSpaceId | Mandatory | URL encoded identifier that uniquely identifies the place where a decision was deployed. |
| operation | Mandatory |
Name of the operation. It is used to identify which decision service to execute within the decision service archive. The operation name is decided at authoring time. |
| decisionServiceId | Mandatory |
Query parameter that identifies the decision project from which the decision service archive is built. The decision service ID is decided at authoring time. Its value is that of the
|
Request body
You can use the decision runtime REST API to call decisions by using the JSON payload.
{
"executionId": "<value_1>",
"input": "<value_2>",
"executionTraceFilters": "<value_3>"
}
| Parameter | Mandatory or Optional | Description |
|---|---|---|
| executionId | Optional |
Optional identifier for the execution of the decision service. If this parameter is not set, the decision runtime creates a decision execution identifier that is globally unique. |
| input | Mandatory |
JSON object that represents input data of the decision service. The JSON object can be obtained from the Run part in Decision Designer by editing the JSON data set. |
| executionTraceFilters | Optional |
JSON object that specifies which traces are activated in which format. If this parameter is not set, the execution trace is For more information about this parameter, see the Schemas section in Runtime REST API reference. Note: If you want to include an exception stack trace in the response payload when an incident
occurs, you must set the decisionRuntimeService.stackTraceEnabled parameter to
true at the time of installing the product. By default, this parameter is set to
false.For more information about this parameter, see IBM Automation Decision Services parameters. |
{
"executionId": "executionId_0001",
"input": {
"customer": {
"name": "Mary",
"age": 20
},
"ageLimit": 21
},
"executionTraceFilters": {
"executionDuration": true,
"printedMessages": true,
"decisionModel": {
"inputParameters": "Object",
"outputParameters": "Object",
"inputNode": "Object",
"outputNode": "Object"
},
"rules": {
"boundObjectsAtStart": "Object",
"boundObjectsAtEnd": "Object",
"allRules": true,
"executedRules": true,
"nonExecutedRules": true
},
"ruleflow": {
"allTasks": false,
"executedTasks": false,
"notExecutedTasks": false,
"selectedRules": false
}
}
}HTTP return codes and execution results
When your client application calls a decision service, you get an HTTP return code. The response body is formatted in JSON payload.
| HTTP return code | Description |
|---|---|
| 200 |
The decision execution completed successfully. The output of the decision is returned in the response body. |
| 404 |
The value of decisionId or operation is invalid. You see the following message in the response
body:
|
| 500 |
An error occurred while processing the decision execution request. An error message is returned in the response body. |
{
"decisionId": "<value_5>",
"decisionOperation": "<value_6>",
"executionId": "<value_7>",
"executionTrace": "<value_8>",
"output": "<value_9>",
"incident": {
"incidentID": "<incident_ID>",
"incidentCategory": "<error_message>",
"stackTrace": "<xyzException>:<stack_message>"
}
}- executionTrace might be null if no execution trace filter is set.
- output might be null if the execution is not completed due to an error.
- incident is returned only when errors occur.
{
"decisionId": "decisions/My-Getting-Started/mySalutationDecisionService/1.0.0-SNAPSHOT/mySalutationDecisionService-1.0.0-20200120.153649-11.jar",
"decisionOperation": "myModel",
"executionId": "24543a29-ce83-4e20-afbc-93fccf7949d5",
"executionTrace": null,
"output": "Good evening Prof. Jones!"
}{
"decisionId": "decisions/My-Getting-Started/mySalutationDecisionService/1.0.0-SNAPSHOT/mySalutationDecisionService-1.0.0-20200120.153649-11.jar",
"decisionOperation": "myModel",
"executionId": "1f10653a-c21f-4653-854e-c6e56da4bdaf",
"executionTrace": null,
"output": null,
"incident": {
"incidentId": "edee977a-5d2e-47ca-b31e-4e866649016c",
"incidentCategory": "Decision error",
"stackTrace": "com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field \"nme\" (class newtype), ... }
}