skip to main content
Corticon Server: Integration & Deployment Guide : Request and response examples : JSON/RESTful request and response messages : Sample JSON request and response messages
 

Try Corticon Now
Sample JSON request and response messages
You can set the Decision Service being called into the URL, or include in the message header.

Passing the Decision Service as a URL parameter

A GET request lets you add URL encoding of parameters so that you can pass a Decision Service and its version in URL parameters instead of the message header. . For example, the following request would get the properties for a Decision Service ProcessOrder version 1.16, with the GET parameters shown in bold:
http://<serverHost>:8850/axis/corticon/decisionService/getProperties
?name=ProcessOrder&majorVersion=1&minorVersion=16
Evaluation of a request will look first for the URL parameter, and if not found, it will look for it as an HTTP header.

Setting the Decision Service information in the HTTP(S) header

The Decision Service payload is enclosed in the request message's body in the JSON object form. The JSON object structure is specified in a separate document.
You must specify the Decision Service name in the HTTP header field dsname, as shown in this example for ProcessOrder:

content-type:application/json
dsName:ProcessOrder
content-length:5479
host:localhost:8850
connection:Keep-Alive
user-agent:Apache-HttpClient/4.3.4 (java 1.5)
accept-encoding:gzip,deflate
Because neither a version or effective date is provided, the highest major version's highest minor version applies.

content-type:application/json
dsName:ProcessOrder
dsMajorVersion:1
...
With only the major version provided, the highest minor version of that major version applies.

content-type:application/json
dsName:ProcessOrder
dsMajorVersion:1
dsMinorVersion:10
...
When both major and minor version are provided, that version of the Decision Service handles the request.

content-type:application/json
dsName:ProcessOrder
dsEffectiveTimestamp:12/11/2015
...
When the header provides effective timestamp instead of major or major/minor version, the request is handled by the Decision Service that is in effect within the range of the given date.

How the CorticonExecuteRest REST API reads the JSON request header

Once the header is complete, the request connects to the host, and submits the JSON request to the designated Decision Service.
The CorticonExecuteRest REST API looks inside the header for the version numbers and effective date information.
Code inside CorticonExecuteRest REST API:
String lstrDecisionServiceName = request.getHeader(ICcServer.REST_HEADER_DECISION_SERVICE_NAME);
String lstrDecisionServiceMajorVersion = request.getHeader(ICcServer.REST_HEADER_DECISION_SERVICE_MAJOR_VERSION);
String lstrDecisionServiceMinorVersion = request.getHeader(ICcServer.REST_HEADER_DECISION_SERVICE_MINOR_VERSION);
String lstrDecisionServiceEffectiveTimestamp = request.getHeader(ICcServer.REST_HEADER_DECISION_SERVICE_EFFECTIVE_TIMESTAMP);
Constant values inside ICcServer:
public static final String REST_HEADER_DECISION_SERVICE_NAME = "dsName";
public static final String REST_HEADER_DECISION_SERVICE_MAJOR_VERSION = "dsMajorVersion";
public static final String REST_HEADER_DECISION_SERVICE_MINOR_VERSION = "dsMinorVersion";
public static final String REST_HEADER_DECISION_SERVICE_EFFECTIVE_TIMESTAMP = "dsEffectiveTimestamp";
It is recommended that you use the ICcServer Constant values rather than the literal values inside your application code.

Basic structure of JSON output

The original JSON Input is updated dynamically when rules fire. However, at the end of rule processing, the Rule Messages from the rules, are added to the JSON output and returned to the user. On the original JSON Object, a new Attribute named “Messages” is added. The “value” could be null or a JSON Object. If the value is a null, that means that no Rule Messages were created by rule processing. If the value is a JSON Object, then there will be an Attribute “name” of “Message” with a “value” of JSONArray. Each JSON Object in the JSON Array represents one Rule Message that was created during rule processing. Inside each JSON Object, there will be an “entityReference”, “text”, “severity”, and also a “__metadata”. The first three map to the Rule Message in the rules, and the “__metadata” contains the #type to ensure a good type casting.

{
"Objects": [<JSONArray>
],
"__metadataRoot": {
<execution property>: “<value”,
.
.
},
"Messages": {
"Message": [
{
"entityReference": "<#id of referenced Entity>",
"text": "<Rule Messages Text>",
"severity": "<Severity>",
"__metadata":
{
"#type": "#RuleMessage"}
},
"version": "<version of the Decision Service>"
},
}
}
Example of Messages in the output returned to user:

{
"Messages": {
"Message": [
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,5] A restricted account [ Sears ] can't be involved in a trade.",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,4] No account [ Airbus ] involved in a trade can exceed its maximum
percentage [ 70.000000 ] for High Yield securities [ 86.156842

].",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,4] No account [ Sears ] involved in a trade can exceed its maximum
percentage [ 65.000000 ] for High Yield securities [ 79.980241
].",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
"__metadata": {"#type": "#RuleMessages"},
“version": "0.0"
},
"Objects": [{
"dMarketValueBeforeTrade": 20432666,
"price": "950.000000",
"transaction": [
{
"dPositionHiGrade": 0,
"dPositionHiYield": 269397.538944,
"dAccruedInterest": 2249.666294,
.
.
.
.
}

Sample JSON Input and Output

The following code presents the input and output of the TradeAllocation sample's AllocateTrade Tester.
JSON Input:

{
"Objects": [{
"dMarketValueBeforeTrade": "10216333.000000",
"price": "950.000000",
"transaction": [
{
"account": [{
"maxPctHiYield": "35.000000",
"dPositionHiYield": "330000.000000",
"dPositionHiGrade": "819167.000000",
"securityPosition": [
{
"quantity": "5000",
"dMarketValue": "819167.000000",
"security": [{
"symbol": "PMBND",
"yield": "6.000000",
"daysInHolding": "23",
"dMarketValue": "164.000000",
"dProfile": "HI-GRD",
"dAnnualInterestAmt": "60.000000",
"price": "160.000000",
"issuer": "Phillip Morris",
"sin": "Y",
"dAccruedInterest": "4.000000",
"faceValue": "1000.000000",
"rating": "A",
"__metadata": {
"#id": "Security_id_1",
"#type": "Security"
}
}],
"__metadata": {
"#id": "SecurityPosition_id_1",
"#type": "SecurityPosition"
}
},
{
"quantity": "3000",
"dMarketValue": "330000.000000",
"security": [{
"symbol": "3MBND",
"yield": "12.000000",
"daysInHolding": "40",
"dMarketValue": "110.000000",
"dProfile": "HI-YLD",
"dAnnualInterestAmt": "90.000000",
"price": "100.000000",
"issuer": "3M",
"sin": "N",
"dAccruedInterest": "10.000000",
"faceValue": "1000.000000",
"rating": "B",
"__metadata": {
"#id": "Security_id_3",
"#type": "Security"
}
}],
"__metadata": {
"#id": "SecurityPosition_id_2",
"#type": "SecurityPosition"
}
}
],
"warnMargin": "3.000000",
"name": "Boeing",
"restricted": "false",
"maxPctHiGrade": "75.000000",
"number": "1640",
"dMarketValue": "1149167.000000",
"__metadata": {
"#id": "Account_id_1",
"#type": "Account"
}
}],
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "Transaction_id_1",
"#type": "Transaction"
}
},
{
"account": [{
"maxPctHiYield": "65.000000",
"dPositionHiYield": "2495556.000000",
"dPositionHiGrade": "819167.000000",
"securityPosition": [
{
"quantity": "5000",
"dMarketValue": "819167.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_1"}}],
"__metadata": {
"#id": "SecurityPosition_id_3",
"#type": "SecurityPosition"
}
},
{
"quantity": "2000",
"dMarketValue": "295556.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "SecurityPosition_id_4",
"#type": "SecurityPosition"
}
},
{
"quantity": "20000",
"dMarketValue": "2200000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_3"}}],
"__metadata": {
"#id": "SecurityPosition_id_5",
"#type": "SecurityPosition"
}
}
],
"warnMargin": "3.000000",
"name": "Sears",
"restricted": "true",
"maxPctHiGrade": "45.000000",
"number": "1920",
"dMarketValue": "3314722.000000",
"__metadata": {
"#id": "Account_id_2",
"#type": "Account"
}
}],
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "Transaction_id_2",
"#type": "Transaction"
}
},
{
"account": [{
"maxPctHiYield": "70.000000",
"dPositionHiYield": "4769444.000000",
"dPositionHiGrade": "983000.000000",
"securityPosition": [
{
"quantity": "6000",
"dMarketValue": "983000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_1"}}],
"__metadata": {
"#id": "SecurityPosition_id_6",
"#type": "SecurityPosition"
}
},
{
"quantity": "2500",
"dMarketValue": "369444.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "SecurityPosition_id_7",
"#type": "SecurityPosition"
}
},
{
"quantity": "40000",
"dMarketValue": "4400000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_3"}}],
"__metadata": {
"#id": "SecurityPosition_id_8",
"#type": "SecurityPosition"
}
}
],
"warnMargin": "2.000000",
"name": "Airbus",
"restricted": "false",
"maxPctHiGrade": "35.000000",
"number": "2750",
"dMarketValue": "5752444.000000",
"__metadata": {
"#id": "Account_id_3",
"#type": "Account"
}
}],
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "Transaction_id_3",
"#type": "Transaction"
}
}
],
"dAccruedInterest": "38889.000000",
"quantity": "5000.000000",
"security": {
"symbol": "BGBND",
"yield": "11.000000",
"daysInHolding": "40",
"dMarketValue": "148.000000",
"dProfile": "HI-YLD",
"dAnnualInterestAmt": "80.000000",
"price": "140.000000",
"issuer": "Boeing",
"sin": "N",
"dAccruedInterest": "8.000000",
"faceValue": "1000.000000",
"rating": "BBB",
"__metadata": {
"#id": "Security_id_2",
"#type": "Security"
}
},
"__metadata": {
"#id": "Trade_id_1",
"#type": "Trade"
}
}],
"__metadataRoot": {
"#restrictInfoRuleMessages": "true",
"#restrictViolationRuleMessages": "true",
"#restrictWarningRuleMessages": "false"
}
}
JSON TRANSLATION = 78
JSON Output:

{
"Messages": {
"Message": [
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,5] A restricted account [ Sears ] can't be involved in a trade.",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,4] No account [ Airbus ] involved in a trade can exceed
its maximum percentage [ 70.000000 ] for High Yield securities [ 86.156842 ].",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,4] No account [ Sears ] involved in a trade can exceed
its maximum percentage [ 65.000000 ] for High Yield securities [ 79.980241 ].",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Trade_id_1",
"text": "[AccountConstraint,4] No account [ Boeing ] involved in a trade can exceed
its maximum percentage [ 35.000000 ] for High Yield securities [ 42.253808 ].",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
}
],
"__metadata": {"#type": "#RuleMessages"},
"version": "0.0"
},
"Objects": [{
"dMarketValueBeforeTrade": 20432666,
"price": "950.000000",
"transaction": [
{
"dPositionHiGrade": 0,
"dPositionHiYield": 269397.538944,
"dAccruedInterest": 2249.666294,
"dActualQuantity": 281.208287,
"account": [{
"dPctHiYield": 42.253808,
"dPositionHiYield": "330000.000000",
"dNewPositionHiGrade": 819167,
"maxPctHiGrade": "75.000000",
"restricted": "false",
"dMarketValue": "1149167.000000",
"number": "1640",
"dPositionHiGrade": "819167.000000",
"maxPctHiYield": "35.000000",
"dNewPositionHiYield": 599397.538944,
"name": "Boeing",
"warnMargin": "3.000000",
"securityPosition": [
{
"quantity": "5000",
"dMarketValue": "819167.000000",
"security": [{
"symbol": "PMBND",
"yield": "6.000000",
"daysInHolding": "23",
"dMarketValue": "164.000000",
"dProfile": "HI-GRD",
"dAnnualInterestAmt": "60.000000",
"price": "160.000000",
"issuer": "Phillip Morris",
"sin": "Y",
"dAccruedInterest": "4.000000",
"faceValue": "1000.000000",
"rating": "A",
"__metadata":
{
"#id": "Security_id_1",
"#type": "Security"
}
}],
"__metadata":{
"#id": "SecurityPosition_id_1",
"#type": "SecurityPosition"
}
},
{
"quantity": "3000",
"dMarketValue": "330000.000000",
"security": [{
"symbol": "3MBND",
"yield": "12.000000",
"daysInHolding": "40",
"dMarketValue": "110.000000",
"dProfile": "HI-YLD",
"dAnnualInterestAmt": "90.000000",
"price": "100.000000",
"issuer": "3M",
"sin": "N",
"dAccruedInterest": "10.000000",
"faceValue": "1000.000000",
"rating": "B",
"__metadata":{
"#id": "Security_id_3",
"#type": "Security"
}
}],
"__metadata":{
"#id": "SecurityPosition_id_2",
"#type": "SecurityPosition"
}
}
],
"__metadata":{
"#id": "Account_id_1",
"#type": "Account"
},
"dNewMarketValue": 1418564.538944,
"dPctHiGrade": 57.746192
}],
"dMarketValue": 269397.538944,
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"dQuantity": 281.208287,
"__metadata":{
"#id": "Transaction_id_1",
"#type": "Transaction"
},
"dPrice": 950
},
{
"dPositionHiGrade": 0,
"dPositionHiYield": 777065.429329,
"dAccruedInterest": 6489.064129,
"dActualQuantity": 811.133016,
"account": [{
"dPctHiYield": 79.980241,
"dPositionHiYield": "2495556.000000",
"dNewPositionHiGrade": 819167,
"maxPctHiGrade": "45.000000",
"restricted": "true",
"dMarketValue": "3314722.000000",
"number": "1920",
"dPositionHiGrade": "819167.000000",
"maxPctHiYield": "65.000000",
"dNewPositionHiYield": 3272621.429329,
"name": "Sears",
"warnMargin": "3.000000",
"securityPosition": [{
"quantity": "5000",
"dMarketValue": "819167.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_1"}}],
"__metadata": {
"#id": "SecurityPosition_id_3",
"#type": "SecurityPosition"
}
},
{
"quantity": "2000",
"dMarketValue": "295556.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "SecurityPosition_id_4",
"#type": "SecurityPosition"
}
},
{
"quantity": "20000",
"dMarketValue": "2200000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_3"}}],
"__metadata": {
"#id": "SecurityPosition_id_5",
"#type": "SecurityPosition"
}
}
],
"__metadata":{
"#id": "Account_id_2",
"#type": "Account"
},
"dNewMarketValue": 4091787.429329,
"dPctHiGrade": 20.019784
}],
"dMarketValue": 777065.429329,
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"dQuantity": 811.133016,
"__metadata": {
"#id": "Transaction_id_2",
"#type": "Transaction"
},
"dPrice": 950
},
{
"dPositionHiGrade": 0,
"dPositionHiYield": 1348537.031727,
"dAccruedInterest": 11261.269577,
"dActualQuantity": 1407.658697,
"account": [{
"dPctHiYield": 86.156842,
"dPositionHiYield": "4769444.000000",
"dNewPositionHiGrade": 983000,
"maxPctHiGrade": "35.000000",
"restricted": "false",
"dMarketValue": "5752444.000000",
"number": "2750",
"dPositionHiGrade": "983000.000000",
"maxPctHiYield": "70.000000",
"dNewPositionHiYield": 6117981.031727,
"name": "Airbus",
"warnMargin": "2.000000",
"securityPosition": [{
"quantity": "6000",
"dMarketValue": "983000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_1"}}],
"__metadata": {
"#id": "SecurityPosition_id_6",
"#type": "SecurityPosition"
}
},
{
"quantity": "2500",
"dMarketValue": "369444.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"__metadata": {
"#id": "SecurityPosition_id_7",
"#type": "SecurityPosition"
}
},
{
"quantity": "40000",
"dMarketValue": "4400000.000000",
"security": [{"__metadata": {"#ref_id": "Security_id_3"}}],
"__metadata": {
"#id": "SecurityPosition_id_8",
"#type": "SecurityPosition"
}
}
],
"__metadata": {
"#id": "Account_id_3",
"#type": "Account"
},
"dNewMarketValue": 7100981.031727,
"dPctHiGrade": 13.843158
}],
"dMarketValue": 1348537.031727,
"security": [{"__metadata": {"#ref_id": "Security_id_2"}}],
"dQuantity": 1407.658697,
"__metadata": {
"#id": "Transaction_id_3",
"#type": "Transaction"
},
"dPrice": 950
}
],
"dAccruedInterest": 40000,
"quantity": "5000.000000",
"security": {
"symbol": "BGBND",
"yield": "11.000000",
"daysInHolding": "40",
"dMarketValue": "148.000000",
"dProfile": "HI-YLD",
"dAnnualInterestAmt": "80.000000",
"price": "140.000000",
"issuer": "Boeing",
"sin": "N",
"dAccruedInterest": "8.000000",
"faceValue": "1000.000000",
"rating": "BBB",
"__metadata": {
"#id": "Security_id_2",
"#type": "Security"
}
},
"__metadata": {
"#id": "Trade_id_1",
"#type": "Trade"
}
}],
"__metadataRoot": {
"#restrictInfoRuleMessages": "true",
"#restrictViolationRuleMessages": "true",
"#restrictWarningRuleMessages": "false"
}
}

Testing a JSON request

Your installation provides a sample JSON request as well as an API test to run the request. For an example of running a Corticon JSON-formatted request on Corticon Java server, see Path 4: Using JSON/RESTful client to consume a Decision Service on Java Server , and on Corticon Server for .NET, see Path 4: Using JSON/RESTful client to consume a Decision Service on .NET server .