Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkStringBuilder.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkStringBuilder sbRequestBody;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *code;
BOOL isSuccess;
const char *message;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "setupName": "Product Qualificiation eligibility",
// "fullName": "ProductQualificationEligibility",
// "description": "Eligiblity of Products using Qualification Rules",
// "usageType": "ProductEligibility",
// "sourceType": "SingleSobject",
// "sourceObject": "AccountFeed",
// "status": "Draft",
// "decisionResultPolicy": "UniqueValues",
// "collectOperator": "Count",
// "conditionType": "Any",
// "conditionCriteria": "1 OR 2 OR 3",
// "parameters": [
// {
// "fieldName": "IsDeleted",
// "usage": "INPUT",
// "operator": "Equals",
// "sequence": "1"
// },
// {
// "fieldName": "Id",
// "usage": "INPUT",
// "operator": "Equals",
// "sequence": "2"
// },
// {
// "fieldName": "Title",
// "usage": "INPUT",
// "operator": "Equals",
// "sequence": "3"
// },
// {
// "fieldName": "CreatedById",
// "usage": "OUTPUT"
// }
// ]
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"setupName","Product Qualificiation eligibility");
CkJsonObject_UpdateString(json,"fullName","ProductQualificationEligibility");
CkJsonObject_UpdateString(json,"description","Eligiblity of Products using Qualification Rules");
CkJsonObject_UpdateString(json,"usageType","ProductEligibility");
CkJsonObject_UpdateString(json,"sourceType","SingleSobject");
CkJsonObject_UpdateString(json,"sourceObject","AccountFeed");
CkJsonObject_UpdateString(json,"status","Draft");
CkJsonObject_UpdateString(json,"decisionResultPolicy","UniqueValues");
CkJsonObject_UpdateString(json,"collectOperator","Count");
CkJsonObject_UpdateString(json,"conditionType","Any");
CkJsonObject_UpdateString(json,"conditionCriteria","1 OR 2 OR 3");
CkJsonObject_UpdateString(json,"parameters[0].fieldName","IsDeleted");
CkJsonObject_UpdateString(json,"parameters[0].usage","INPUT");
CkJsonObject_UpdateString(json,"parameters[0].operator","Equals");
CkJsonObject_UpdateString(json,"parameters[0].sequence","1");
CkJsonObject_UpdateString(json,"parameters[1].fieldName","Id");
CkJsonObject_UpdateString(json,"parameters[1].usage","INPUT");
CkJsonObject_UpdateString(json,"parameters[1].operator","Equals");
CkJsonObject_UpdateString(json,"parameters[1].sequence","2");
CkJsonObject_UpdateString(json,"parameters[2].fieldName","Title");
CkJsonObject_UpdateString(json,"parameters[2].usage","INPUT");
CkJsonObject_UpdateString(json,"parameters[2].operator","Equals");
CkJsonObject_UpdateString(json,"parameters[2].sequence","3");
CkJsonObject_UpdateString(json,"parameters[3].fieldName","CreatedById");
CkJsonObject_UpdateString(json,"parameters[3].usage","OUTPUT");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
sbRequestBody = CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
resp = CkHttp_PTextSb(http,"PATCH","https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/definitions/:decisionTableId",sbRequestBody,"utf-8","application/json",FALSE,FALSE);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
return;
}
sbResponseBody = CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Failed.\n");
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "code": "200",
// "isSuccess": true,
// "message": ""
// }
// 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.
code = CkJsonObject_stringOf(jResp,"code");
isSuccess = CkJsonObject_BoolOf(jResp,"isSuccess");
message = CkJsonObject_stringOf(jResp,"message");
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -X PATCH
-H "Authorization: Bearer <access_token>"
-d '{
"setupName":"Product Qualificiation eligibility",
"fullName":"ProductQualificationEligibility",
"description":"Eligiblity of Products using Qualification Rules",
"usageType":"ProductEligibility",
"sourceType":"SingleSobject",
"sourceObject":"AccountFeed",
"status":"Draft",
"decisionResultPolicy":"UniqueValues",
"collectOperator":"Count",
"conditionType":"Any",
"conditionCriteria":"1 OR 2 OR 3",
"parameters":[
{
"fieldName":"IsDeleted",
"usage":"INPUT",
"operator":"Equals",
"sequence":"1"
},
{
"fieldName":"Id",
"usage":"INPUT",
"operator":"Equals",
"sequence":"2"
},
{
"fieldName":"Title",
"usage":"INPUT",
"operator":"Equals",
"sequence":"3"
},
{
"fieldName":"CreatedById",
"usage":"OUTPUT"
}
]
}'
https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/definitions/:decisionTableId
Postman Collection Item JSON
{
"name": "Update Table",
"request": {
"method": "PATCH",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"setupName\":\"Product Qualificiation eligibility\",\n \"fullName\":\"ProductQualificationEligibility\",\n \"description\":\"Eligiblity of Products using Qualification Rules\",\n \"usageType\":\"ProductEligibility\",\n \"sourceType\":\"SingleSobject\",\n \"sourceObject\":\"AccountFeed\",\n \"status\":\"Draft\",\n \"decisionResultPolicy\":\"UniqueValues\",\n \"collectOperator\":\"Count\",\n \"conditionType\":\"Any\",\n \"conditionCriteria\":\"1 OR 2 OR 3\",\n \"parameters\":[\n {\n \"fieldName\":\"IsDeleted\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"1\"\n },\n {\n \"fieldName\":\"Id\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"2\"\n },\n {\n \"fieldName\":\"Title\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"3\"\n },\n {\n \"fieldName\":\"CreatedById\",\n \"usage\":\"OUTPUT\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/definitions/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
"definitions",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Po3",
"description": "Decision Table Id"
}
]
},
"description": "# Decision Table Definitions ( DELETE)\n\nDelete a decision table definition associated with a decision table.\n\nResource\n\n```\n/connect/business-rules/decision-table/definitions/${decisionTableId}\n\n ```\n\nResource Example\n\n```\nhttps://yourInstance.salesforce.com/services/data/v59.0/connect/business-rules/decision-table/definitions/0lDxx00000002Ur\n\n ```\n\nAvailable version\n\n58.0\n\nRequires Chatter\n\nNo\n\nHTTP methods\n\nDELETE\n\nResponse body for DELETE\n\n[Decision Table Output](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_output.htm)\n\n# Decision Table Output\n\nOutput representation of the decision table details.JSON example for GET, POST, and PATCH\n\n```\n{\n \"code\":\"200\",\n \"decisionTable\":{\n \"collectOperator\":\"Count\",\n \"conditionCriteria\":\"1 OR 2 OR 3\",\n \"conditionType\":\"Any\",\n \"decisionResultPolicy\":\"UniqueValues\",\n \"description\":\"Eligiblity of Products using Qualification Rules\",\n \"id\":\"0lDxx00000000BJ\",\n \"parameters\":[\n {\n \"fieldName\":\"IsDeleted\",\n \"isGroupByField\":false,\n \"isPriority\":false,\n \"operator\":\"Equals\",\n \"sequence\":1,\n \"usage\":\"Input\"\n },\n {\n \"fieldName\":\"CreatedById\",\n \"isGroupByField\":false,\n \"isPriority\":false,\n \"usage\":\"Output\"\n },\n {\n \"fieldName\":\"Title\",\n \"isGroupByField\":false,\n \"isPriority\":false,\n \"operator\":\"Equals\",\n \"sequence\":3,\n \"usage\":\"Input\"\n },\n {\n \"fieldName\":\"Id\",\n \"isGroupByField\":false,\n \"isPriority\":false,\n \"operator\":\"Equals\",\n \"sequence\":2,\n \"usage\":\"Input\"\n }\n ],\n \"setupName\":\"Product Qualificiation eligibility3\",\n \"sourceCriteria\":[\n \n ],\n \"sourceObject\":\"AccountFeed\",\n \"sourceType\":\"SingleSobject\",\n \"sourceconditionLogic\":\"1 AND 2 AND 3\",\n \"status\":\"Draft\"\n },\n \"isSuccess\":true,\n \"message\":\"\"\n}\n\n ```\n\nJSON example for DELETE\n\n```\n{\n \"code\":\"200\",\n \"isSuccess\":true,\n \"message\":\"\"\n}\n\n ```\n\n| Property Name | Type | Description | Filter Group and Version | Available Version |\n| --- | --- | --- | --- | --- |\n| code | String | Response code from the API request. | Small, 58.0 | 58.0 |\n| decisionTable | [Decision Table Definition Output](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_definition_output.htm) | Details of the decision table definition associated with the decision table. | Small, 58.0 | 58.0 |\n| isSuccess | Boolean | Indicates whether the API request is successful (true) or not (false). | Small, 58.0 | 58.0 |\n| message | String | Error message when the API request fails. | Small, 58.0 | 58.0 |"
},
"response": [
{
"name": "Status200-Success",
"originalRequest": {
"method": "PATCH",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"setupName\":\"Product Qualificiation eligibility\",\n \"fullName\":\"ProductQualificationEligibility\",\n \"description\":\"Eligiblity of Products using Qualification Rules\",\n \"usageType\":\"ProductEligibility\",\n \"sourceType\":\"SingleSobject\",\n \"sourceObject\":\"AccountFeed\",\n \"status\":\"Draft\",\n \"decisionResultPolicy\":\"UniqueValues\",\n \"collectOperator\":\"Count\",\n \"conditionType\":\"Any\",\n \"conditionCriteria\":\"1 OR 2 OR 3\",\n \"parameters\":[\n {\n \"fieldName\":\"IsDeleted\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"1\"\n },\n {\n \"fieldName\":\"Id\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"2\"\n },\n {\n \"fieldName\":\"Title\",\n \"usage\":\"INPUT\",\n \"operator\":\"Equals\",\n \"sequence\":\"3\"\n },\n {\n \"fieldName\":\"CreatedById\",\n \"usage\":\"OUTPUT\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/definitions/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
"definitions",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Po3",
"description": "Decision Table Id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 14:02:00 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 \"code\": \"200\",\n \"isSuccess\": true,\n \"message\": \"\"\n}"
}
]
}