Back to Collection Items
#include <CkHttp.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>
#include <CkStringBuilder.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "conditions": {
// "conditionsList": [
// {
// "fieldName": "IsDeleted",
// "value": true
// }
// ]
// }
// }
CkJsonObject json;
json.UpdateString("conditions.conditionsList[0].fieldName","IsDeleted");
json.UpdateBool("conditions.conditionsList[0].value",true);
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken("<access_token>");
CkHttpResponse *resp = http.PostJson3("https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId","application/json",json);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkStringBuilder sbResponseBody;
resp->GetBodySb(sbResponseBody);
CkJsonObject jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << jResp.emit() << "\r\n";
int respStatusCode = resp->get_StatusCode();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << resp->header() << "\r\n";
std::cout << "Failed." << "\r\n";
delete resp;
return;
}
delete resp;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "errorCode": null,
// "errorMessage": null,
// "outcomeList": [
// ],
// "outcomeType": "No Match",
// "successStatus": true
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
const char *errorCode = jResp.stringOf("errorCode");
const char *errorMessage = jResp.stringOf("errorMessage");
const char *outcomeType = jResp.stringOf("outcomeType");
bool successStatus = jResp.BoolOf("successStatus");
int i = 0;
int count_i = jResp.SizeOfArray("outcomeList");
while (i < count_i) {
jResp.put_I(i);
i = i + 1;
}
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"conditions": {
"conditionsList": [
{
"fieldName": "IsDeleted",
"value": true
}
]
}
}'
https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId
Postman Collection Item JSON
{
"name": "Lookup Table",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"IsDeleted\",\n \"value\": true\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Pnt",
"description": "Decision Table Id"
}
]
},
"description": "# Decision Table (Lookup Table)\n\nPerforms a lookup on a decision table.Resource\n\n```\n/connect/business-rules/decision-table/${decisionTableId}\n\n ```\n\nResource Example\n\n```\nhttps://yourInstance.salesforce.com/services/data/v55.0/connect\n/decision-table/0lDB0000000TNQzMAO\n\n ```\n\nAvailable version\n\n55.0\n\nRequires Chatter\n\nNo\n\nHTTP methods\n\nPOST\n\nRequest body for POST\n\nJSON example\n\n```\n{\n \"conditions\" : {\n \"conditionsList\" : [\n {\n \"fieldName\": \"state__c\",\n \"value\": \"MH\"\n },\n {\n \"fieldName\": \"validity__c\",\n \"value\": 30\n }\n ]\n }\n}\n\n ```\n\nProperties\n\n| Name | Type | Description | Required or Optional | Available Version |\n| --- | --- | --- | --- | --- |\n| conditions | [Decision Table Condition](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_requests_decision_table_condition.htm)\\[\\] | The list of decision table conditions on which the decision table executes and provides outcomes. | Required | 55.0 |\n| datasetLinkName | String | The API name of the dataset link provided as an input for the decision table execution. | Optional | 55.0 |\n\nResponse body for POST\n\n[Decision Table Outcome](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_outcome.htm)\n\n# Decision Table Outcome\n\nOutput representation of the decision table execution.JSON example\n\n```\n{\n \"errorCode\" : null,\n \"errorMessage\" : null,\n \"outcomeList\" : [ {\n \"values\" : {\n \"amount__c\" : \"399\",\n \"Name\" : \"MH 005\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"499\",\n \"Name\" : \"MH 006\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"379\",\n \"Name\" : \"MH 007\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"1498\",\n \"Name\" : \"MH 008\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"98\",\n \"Name\" : \"MH 009\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"251\",\n \"Name\" : \"MH 010\"\n }\n } ],\n \"outcomeType\" : \"Multiple Matches\",\n \"successStatus\" : true\n}\n\n ```\n\n| Property Name | Type | Description | Filter Group and Version | Available Version |\n| --- | --- | --- | --- | --- |\n| errorCode | Integer | The error code if transaction fails for any reason. | Small, 55.0 | 55.0 |\n| errorMessage | String | The error message if transaction fails for any reason. | Small, 55.0 | 55.0 |\n| outcomeList | [Decision Table Outcome Item](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_outcome_item.htm)\\[\\] | Outcome list that stores two or more outcomes provided by the decision table. | Small, 55.0 | 55.0 |\n| outcomeType | String | The outcome type after the request is successful. | Small, 55.0 | 55.0 |\n| successStatus | Boolean | Indicates the status of the decision table execution. | Small, 55.0 | 55.0 |"
},
"response": [
{
"name": "Status400-BadRequest",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"state__c\",\n \"value\": \"MH\"\n },\n {\n \"fieldName\": \"validity__c\",\n \"value\": 30\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lIHo000000LFC6MAO",
"description": "Decision Table Id"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 12:16:33 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "[\n {\n \"errorCode\": \"INVALID_ID_FIELD\",\n \"message\": \"Invalid identifier: 0lIHo000000LFC6MAO\"\n }\n]"
},
{
"name": "Status500-UnknownException",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"Comment Count\",\n \"value\": 1\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008PnjMAE",
"description": "Decision Table Id"
}
]
}
},
"status": "Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 12:31:01 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "[\n {\n \"message\": \"An unexpected error occurred. Please include this ErrorId if you contact support: 1716762391-743375 (1633993601)\",\n \"errorCode\": \"UNKNOWN_EXCEPTION\"\n }\n]"
},
{
"name": "Status201-Success",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"IsDeleted\",\n \"value\": true\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Pnt",
"description": "Decision Table Id"
}
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 13:22:05 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"errorCode\": null,\n \"errorMessage\": null,\n \"outcomeList\": [],\n \"outcomeType\": \"No Match\",\n \"successStatus\": true\n}"
}
]
}