Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
BOOL Activateable;
const char *AssociateEntityType;
const char *AssociateParentEntity;
BOOL Createable;
BOOL Custom;
BOOL CustomSetting;
BOOL DeepCloneable;
BOOL Deletable;
BOOL DeprecatedAndHidden;
BOOL FeedEnabled;
BOOL HasSubtypes;
BOOL IsInterface;
BOOL IsSubtype;
const char *KeyPrefix;
const char *Label;
const char *LabelPlural;
BOOL Layoutable;
BOOL Mergeable;
BOOL MruEnabled;
const char *Name;
BOOL Queryable;
BOOL Replicateable;
BOOL Retrieveable;
BOOL Searchable;
BOOL Triggerable;
BOOL Undeletable;
BOOL Updateable;
const char *CompactLayouts;
const char *RowTemplate;
const char *Describe;
const char *Layouts;
const char *Sobject;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
sbResponseBody = CkStringBuilder_Create();
success = CkHttp_QuickGetSb(http,"https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",sbResponseBody);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttp_getLastStatus(http);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttp_lastHeader(http));
printf("Failed.\n");
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "objectDescribe": {
// "activateable": false,
// "associateEntityType": null,
// "associateParentEntity": null,
// "createable": true,
// "custom": false,
// "customSetting": false,
// "deepCloneable": false,
// "deletable": true,
// "deprecatedAndHidden": false,
// "feedEnabled": false,
// "hasSubtypes": false,
// "isInterface": false,
// "isSubtype": false,
// "keyPrefix": "01p",
// "label": "Apex Class",
// "labelPlural": "Apex Classes",
// "layoutable": true,
// "mergeable": false,
// "mruEnabled": true,
// "name": "ApexClass",
// "queryable": true,
// "replicateable": true,
// "retrieveable": true,
// "searchable": true,
// "triggerable": false,
// "undeletable": false,
// "updateable": true,
// "urls": {
// "compactLayouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts",
// "rowTemplate": "/services/data/v59.0/tooling/sobjects/ApexClass/{ID}",
// "describe": "/services/data/v59.0/tooling/sobjects/ApexClass/describe",
// "layouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts",
// "sobject": "/services/data/v59.0/tooling/sobjects/ApexClass"
// }
// },
// "recentItems": [
// ]
// }
// 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.
Activateable = CkJsonObject_BoolOf(jResp,"objectDescribe.activateable");
AssociateEntityType = CkJsonObject_stringOf(jResp,"objectDescribe.associateEntityType");
AssociateParentEntity = CkJsonObject_stringOf(jResp,"objectDescribe.associateParentEntity");
Createable = CkJsonObject_BoolOf(jResp,"objectDescribe.createable");
Custom = CkJsonObject_BoolOf(jResp,"objectDescribe.custom");
CustomSetting = CkJsonObject_BoolOf(jResp,"objectDescribe.customSetting");
DeepCloneable = CkJsonObject_BoolOf(jResp,"objectDescribe.deepCloneable");
Deletable = CkJsonObject_BoolOf(jResp,"objectDescribe.deletable");
DeprecatedAndHidden = CkJsonObject_BoolOf(jResp,"objectDescribe.deprecatedAndHidden");
FeedEnabled = CkJsonObject_BoolOf(jResp,"objectDescribe.feedEnabled");
HasSubtypes = CkJsonObject_BoolOf(jResp,"objectDescribe.hasSubtypes");
IsInterface = CkJsonObject_BoolOf(jResp,"objectDescribe.isInterface");
IsSubtype = CkJsonObject_BoolOf(jResp,"objectDescribe.isSubtype");
KeyPrefix = CkJsonObject_stringOf(jResp,"objectDescribe.keyPrefix");
Label = CkJsonObject_stringOf(jResp,"objectDescribe.label");
LabelPlural = CkJsonObject_stringOf(jResp,"objectDescribe.labelPlural");
Layoutable = CkJsonObject_BoolOf(jResp,"objectDescribe.layoutable");
Mergeable = CkJsonObject_BoolOf(jResp,"objectDescribe.mergeable");
MruEnabled = CkJsonObject_BoolOf(jResp,"objectDescribe.mruEnabled");
Name = CkJsonObject_stringOf(jResp,"objectDescribe.name");
Queryable = CkJsonObject_BoolOf(jResp,"objectDescribe.queryable");
Replicateable = CkJsonObject_BoolOf(jResp,"objectDescribe.replicateable");
Retrieveable = CkJsonObject_BoolOf(jResp,"objectDescribe.retrieveable");
Searchable = CkJsonObject_BoolOf(jResp,"objectDescribe.searchable");
Triggerable = CkJsonObject_BoolOf(jResp,"objectDescribe.triggerable");
Undeletable = CkJsonObject_BoolOf(jResp,"objectDescribe.undeletable");
Updateable = CkJsonObject_BoolOf(jResp,"objectDescribe.updateable");
CompactLayouts = CkJsonObject_stringOf(jResp,"objectDescribe.urls.compactLayouts");
RowTemplate = CkJsonObject_stringOf(jResp,"objectDescribe.urls.rowTemplate");
Describe = CkJsonObject_stringOf(jResp,"objectDescribe.urls.describe");
Layouts = CkJsonObject_stringOf(jResp,"objectDescribe.urls.layouts");
Sobject = CkJsonObject_stringOf(jResp,"objectDescribe.urls.sobject");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"recentItems");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
i = i + 1;
}
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME
Postman Collection Item JSON
{
"name": "Get Tooling Metadata SObject",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tooling",
"sobjects",
":SOBJECT_API_NAME"
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": ""
}
]
}
},
"response": [
{
"name": "Get Tooling Metadata SObject",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tooling",
"sobjects",
":SOBJECT_API_NAME"
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": "ApexClass"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Mon, 11 Dec 2023 10:36:20 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Sforce-Limit-Info",
"value": "api-usage=298/15000"
},
{
"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 \"objectDescribe\": {\n \"activateable\": false,\n \"associateEntityType\": null,\n \"associateParentEntity\": null,\n \"createable\": true,\n \"custom\": false,\n \"customSetting\": false,\n \"deepCloneable\": false,\n \"deletable\": true,\n \"deprecatedAndHidden\": false,\n \"feedEnabled\": false,\n \"hasSubtypes\": false,\n \"isInterface\": false,\n \"isSubtype\": false,\n \"keyPrefix\": \"01p\",\n \"label\": \"Apex Class\",\n \"labelPlural\": \"Apex Classes\",\n \"layoutable\": true,\n \"mergeable\": false,\n \"mruEnabled\": true,\n \"name\": \"ApexClass\",\n \"queryable\": true,\n \"replicateable\": true,\n \"retrieveable\": true,\n \"searchable\": true,\n \"triggerable\": false,\n \"undeletable\": false,\n \"updateable\": true,\n \"urls\": {\n \"compactLayouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts\",\n \"rowTemplate\": \"/services/data/v59.0/tooling/sobjects/ApexClass/{ID}\",\n \"describe\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe\",\n \"layouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts\",\n \"sobject\": \"/services/data/v59.0/tooling/sobjects/ApexClass\"\n }\n },\n \"recentItems\": []\n}"
}
]
}