Running the sample JSON Request on .NET server
A Corticon Server installation provides a JSON sample and a test script that runs the sample.
Note: JSON datatypes require double-quotes only on String values. As JSON does not have a date datatype, Corticon treats time values as Strings. When the other datatypes -- Booleans and numbers -- are in quotes, Corticon interprets the datatype from its Vocabulary properties and removes the quotes. Output will conform to the JSON syntax.
The sample, located at [CORTICON_WORK_DIR]\Samples\Rule Projects\OrderProcessing\OrderProcessingPayload.json , is as follows:
{"name": "ProcessOrder", "Objects": [{ "total": null, "shipped": null, "item": [ { "product": "Ball", "price": "10.000000", "quantity": "20", "subtotal": null, "__metadata": { "#id": "Item_id_7", "#type": "Item" } }, { "product": "Racket", "price": "20.000000", "quantity": "1", "subtotal": null, "__metadata": { "#id": "Item_id_8", "#type": "Item" } }, { "product": "Wrist Band", "price": "5.250000", "quantity": "2", "subtotal": null, "__metadata": { "#id": "Item_id_9", "#type": "Item" } } ], "shippedOn": null, "__metadata": { "#id": "Order_id_1", "#type": "Order" }, "dueDate": "1/1/2008", "note": null }, { "total": null, "shipped": null, "item": [ { "product": "Pencil", "price": "1.000000", "quantity": "10", "subtotal": null, "__metadata": { "#id": "Item_id_10", "#type": "Item" } }, { "product": "Notebook", "price": "3.000000", "quantity": "2", "subtotal": null, "__metadata": { "#id": "Item_id_11", "#type": "Item" } }, { "product": "Eraser", "price": "2.000000", "quantity": "1", "subtotal": null, "__metadata": { "#id": "Item_id_12", "#type": "Item" } } ], "shippedOn": null, "__metadata": { "#id": "Order_id_2", "#type": "Order" }, "dueDate": "1/1/2009", "note": null } ]}
Note: The sample sets the Decision Service name as a parameter in the JSON request. You could add other parameters such as the version and effective timestamp, as shown:
{ "name": "string", "majorVersion": "string", "minorVersion": "string", "effectiveTimestamp": "string", "Objects": [
To run the JSON sample:
1. Start Corticon Server the IIS server that is hosting the Corticon .NET application.
2. Open a command prompt window at [CORTICON_HOME]\Server .NET\samples\bin .
3. Launch Corticon-Api-Rest-Test.exe .
4. Enter 142 .
5. When prompted for Input JSON File Path , enter the path to the sample:
C:\Users\{user}\Progress\CorticonWork_5.7\Samples\Rule Projects\OrderProcessing\OrderProcessingPayload.json
The request is processed, and its output is placed at [CORTICON_WORK_DIR]\output with a name formatted as OutputCRString_{epochTime}.json where {epochTime} is the number of seconds that have elapsed since 1/1/1970. The input file is also placed there. The output for the sample is as follows:
{ "Messages": { "Message": [ { "entityReference": "Order_id_2", "text": "The total for the Order is 18.000000.", "severity": "Info", "__metadata": {"#type": "#RuleMessage"} }, { "entityReference": "Order_id_1", "text": "The total for the Order is 230.500000.", "severity": "Info", "__metadata": {"#type": "#RuleMessage"} }, { "entityReference": "Order_id_1", "text": "This Order was shipped late. Ship date 12/1/2008", "severity": "Warning", "__metadata": {"#type": "#RuleMessage"} }, { "entityReference": "Order_id_2", "text": "This Order was shipped on time. Ship date 12/1/2008", "severity": "Info", "__metadata": {"#type": "#RuleMessage"} } ], "__metadata": {"#type": "#RuleMessages"}, "version": "1.10" }, "Objects": [ { "total": 230.5, "shipped": true, "item": [ { "product": "Ball", "price": "10.000000", "quantity": "20", "__metadata": { "#type": "Item", "#id": "Item_id_7" }, "subtotal": 200 }, { "product": "Racket", "price": "20.000000", "quantity": "1", "__metadata": { "#type": "Item", "#id": "Item_id_8" }, "subtotal": 20 }, { "product": "Wrist Band", "price": "5.250000", "quantity": "2", "__metadata": { "#type": "Item", "#id": "Item_id_9" }, "subtotal": 10.5 } ], "shippedOn": "12/1/2008", "__metadata": { "#type": "Order", "#id": "Order_id_1" }, "dueDate": "1/1/2008", "note": "This Order was shipped late" }, { "total": 18, "shipped": true, "item": [ { "product": "Pencil", "price": "1.000000", "quantity": "10", "__metadata": { "#type": "Item", "#id": "Item_id_10" }, "subtotal": 10 }, { "product": "Notebook", "price": "3.000000", "quantity": "2", "__metadata": { "#type": "Item", "#id": "Item_id_11" }, "subtotal": 6 }, { "product": "Eraser", "price": "2.000000", "quantity": "1", "__metadata": { "#type": "Item", "#id": "Item_id_12" }, "subtotal": 2 } ], "shippedOn": "12/1/2008", "__metadata": { "#type": "Order", "#id": "Order_id_2" }, "dueDate": "1/1/2009", "note": "This Order was shipped on time" } ], "name": "ProcessOrder" }