Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *apiName;
const wchar_t *id;
const wchar_t *label;
const wchar_t *listUiUrl;
int count;
const wchar_t *currentPageToken;
const wchar_t *currentPageUrl;
const wchar_t *eTag;
const wchar_t *nextPageToken;
const wchar_t *nextPageUrl;
const wchar_t *objectApiName;
int pageSize;
const wchar_t *previousPageToken;
const wchar_t *previousPageUrl;
const wchar_t *queryString;
BOOL recentListsOnly;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://domain.com/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "count": 6,
// "currentPageToken": "0",
// "currentPageUrl": "/services/data/v58.0/ui-api/list-ui/Account?pageSize=20&pageToken=0",
// "eTag": "7a9cf6dc597cbc985bab8a26df2f1752",
// "lists": [
// {
// "apiName": "AllAccounts",
// "id": "00B58000002ssinEAA",
// "label": "All Accounts",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/AllAccounts"
// },
// {
// "apiName": "MyAccounts",
// "id": "00B58000002ssivEAA",
// "label": "My Accounts",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/MyAccounts"
// },
// {
// "apiName": "NewLastWeek",
// "id": "00B58000002ssiHEAQ",
// "label": "New Last Week",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/NewLastWeek"
// },
// {
// "apiName": "NewThisWeek",
// "id": "00B58000002ssi6EAA",
// "label": "New This Week",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/NewThisWeek"
// },
// {
// "apiName": "PlatinumandGoldSLACustomers",
// "id": "00B58000002ssiXEAQ",
// "label": "Platinum and Gold SLA Customers",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/PlatinumandGoldSLACustomers"
// },
// {
// "apiName": "RecentlyViewedAccounts",
// "id": "00B58000002ssimEAA",
// "label": "Recently Viewed Accounts",
// "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/RecentlyViewedAccounts"
// }
// ],
// "nextPageToken": null,
// "nextPageUrl": null,
// "objectApiName": "Account",
// "pageSize": 20,
// "previousPageToken": null,
// "previousPageUrl": null,
// "queryString": null,
// "recentListsOnly": false
// }
// 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.
count = CkJsonObjectW_IntOf(jResp,L"count");
currentPageToken = CkJsonObjectW_stringOf(jResp,L"currentPageToken");
currentPageUrl = CkJsonObjectW_stringOf(jResp,L"currentPageUrl");
eTag = CkJsonObjectW_stringOf(jResp,L"eTag");
nextPageToken = CkJsonObjectW_stringOf(jResp,L"nextPageToken");
nextPageUrl = CkJsonObjectW_stringOf(jResp,L"nextPageUrl");
objectApiName = CkJsonObjectW_stringOf(jResp,L"objectApiName");
pageSize = CkJsonObjectW_IntOf(jResp,L"pageSize");
previousPageToken = CkJsonObjectW_stringOf(jResp,L"previousPageToken");
previousPageUrl = CkJsonObjectW_stringOf(jResp,L"previousPageUrl");
queryString = CkJsonObjectW_stringOf(jResp,L"queryString");
recentListsOnly = CkJsonObjectW_BoolOf(jResp,L"recentListsOnly");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"lists");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
apiName = CkJsonObjectW_stringOf(jResp,L"lists[i].apiName");
id = CkJsonObjectW_stringOf(jResp,L"lists[i].id");
label = CkJsonObjectW_stringOf(jResp,L"lists[i].label");
listUiUrl = CkJsonObjectW_stringOf(jResp,L"lists[i].listUiUrl");
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME
Postman Collection Item JSON
{
"name": "Get List View for an Object",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"list-ui",
":SOBJECT_API_NAME"
],
"query": [
{
"key": "pageSize",
"value": "",
"description": "The number of list records viewed at one time. The default value is 20. Value can be 1–2000.",
"disabled": true
},
{
"key": "pageToken",
"value": "",
"description": "A token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000 and the default is 0.",
"disabled": true
},
{
"key": "q",
"value": "",
"description": "Query list views that contain certain key words.",
"disabled": true
},
{
"key": "recentListsOnly",
"value": "true",
"description": "Show only recently viewed lists.",
"disabled": true
}
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": "Account",
"description": "Object API name"
}
]
},
"description": "Returns a collection of list views associated with an object."
},
"response": [
{
"name": "Get List View for an Object",
"originalRequest": {
"method": "GET",
"header": [
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"list-ui",
":SOBJECT_API_NAME"
],
"query": [
{
"key": "pageSize",
"value": null,
"description": "The number of list records viewed at one time. The default value is 20. Value can be 1–2000.",
"disabled": true
},
{
"key": "pageToken",
"value": null,
"description": "A token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000 and the default is 0.",
"disabled": true
},
{
"key": "q",
"value": null,
"description": "Query list views that contain certain key words.",
"disabled": true
},
{
"key": "recentListsOnly",
"value": "true",
"description": "Show only recently viewed lists.",
"disabled": true
}
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": "Account",
"description": "Object API name"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Fri, 06 Oct 2023 09:49:33 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": "ETag",
"value": "\"7a9cf6dc597cbc985bab8a26df2f1752--gzip\""
},
{
"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 \"count\": 6,\n \"currentPageToken\": \"0\",\n \"currentPageUrl\": \"/services/data/v58.0/ui-api/list-ui/Account?pageSize=20&pageToken=0\",\n \"eTag\": \"7a9cf6dc597cbc985bab8a26df2f1752\",\n \"lists\": [\n {\n \"apiName\": \"AllAccounts\",\n \"id\": \"00B58000002ssinEAA\",\n \"label\": \"All Accounts\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/AllAccounts\"\n },\n {\n \"apiName\": \"MyAccounts\",\n \"id\": \"00B58000002ssivEAA\",\n \"label\": \"My Accounts\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/MyAccounts\"\n },\n {\n \"apiName\": \"NewLastWeek\",\n \"id\": \"00B58000002ssiHEAQ\",\n \"label\": \"New Last Week\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/NewLastWeek\"\n },\n {\n \"apiName\": \"NewThisWeek\",\n \"id\": \"00B58000002ssi6EAA\",\n \"label\": \"New This Week\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/NewThisWeek\"\n },\n {\n \"apiName\": \"PlatinumandGoldSLACustomers\",\n \"id\": \"00B58000002ssiXEAQ\",\n \"label\": \"Platinum and Gold SLA Customers\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/PlatinumandGoldSLACustomers\"\n },\n {\n \"apiName\": \"RecentlyViewedAccounts\",\n \"id\": \"00B58000002ssimEAA\",\n \"label\": \"Recently Viewed Accounts\",\n \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/RecentlyViewedAccounts\"\n }\n ],\n \"nextPageToken\": null,\n \"nextPageUrl\": null,\n \"objectApiName\": \"Account\",\n \"pageSize\": 20,\n \"previousPageToken\": null,\n \"previousPageUrl\": null,\n \"queryString\": null,\n \"recentListsOnly\": false\n}"
}
]
}