In this task, you learn how to open and explore a RuleApp in the Decision Server console, and test a ruleset with a REST request.
The Decision Server console is used to manage and execute rulesets, trace executions, and display the rules in RuleApps.
In this task, you explore your deployed artifacts in the Decision Server console. You make sure the status of the ruleset is enabled for execution, and send a JSON-formatted REST request to the ruleset.
You view the RuleApp in the Decision Server console and check the status of the ruleset.
Procedure
- Sign in to your instance of the Decision Server console as admin user.
- Click the Explorer tab.
- In the Navigator, expand RuleApps, and then /mydeployment/1.0. You see that the Decision Server console contains version 1.0 of mydeployment, which contains version 1.0 of Miniloan_ServiceRuleset:
- Click /Miniloan_ServiceRuleset/1.0 to view the details of the ruleset in the Ruleset View. The status of the ruleset is enabled, which indicates that the ruleset can be run:
You test the ruleset with a REST request in the Decision Server console.
Procedure
- In the Decision Server console, on the Miniloan_ServiceRuleset page, click Retrieve HTDS Description File.
- Select the REST option, and then choose OpenAPI-JSON for the format.
- Click View and copy the URL. The decision service URL uses the following format:
http(s)://<DSC_ENDPOINT>/DecisionService/rest/v1/mydeployment/1.0/Miniloan_ServiceRuleset/1.0/
Note You can export this URL as
DSC_URL
environment variable to execute the request in Step 3 (optional): Testing the execution of the ruleset using curl.
- Close the web page.
- Back on the Miniloan_ServiceRuleset page, click Retrieve HTDS Description File.
- Make sure REST and OpenAPI-JSON are still selected, and click Test.
- On the REST Service page, replace the entire request description with the following text:
```json
{
"loan": {
"amount":500000,
"duration":240,
"yearlyInterestRate": 0.05
},
"__DecisionID__": "Test",
"borrower": {
"name":"Joe",
"creditScore":600,
"yearlyIncome":80000
}
}
```
- Click Execute request. The Server Response returns the following data:
It shows that the loan is rejected because the debt-to-income ratio is too high.
- Log out of the Decision Server console.
You test the execution of the Miniloan_ServiceRuleset ruleset in a command terminal by using cURL, a command-line tool for getting or sending files by using the URL syntax. This step is optional. If you do not wish to install cURL, you cannot perform this step. It is recommended to go through this step even if you choose not to perform it, as it shows an example of how to execute a ruleset by using an external client.
Procedure
-
Open a command terminal.
-
Go to the location where you previously downloaded (execution-payload.json).
-
Type the following command:
curl -k -X POST -H "Content-Type: application/json" \ -u <admin_user>:<admin_password> -d "@execution-payload.json" \ ${DSC_URL}
Where
DSC_URL
is the URL from Step 2: Testing the ruleset for REST execution.
The command issues a POST request for the URL of your decision service. The execution parameters are stored in the execution-payload.json file.
- Press Enter. The command returns the following output:
It shows that the loan is rejected because the debt-to-income ratio is too high.
You have finished the tutorial, and no longer need the decision service in Decision Center and the Decision Server console. In the next task, you remove the Miniloan decision service from Decision Center and the Decision Server console.