C / Support API / List Views By ID
Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject queryParams;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *active;
const char *Amet_b2;
BOOL Pariatur_d74;
int Eiusmodd7e;
const char *created_at;
const char *default;
const char *description;
const char *Sit_bd1;
int Voluptated;
const char *id;
const char *position;
const char *Officia_1c;
const char *title;
const char *updated_at;
int Do_99;
BOOL Aliqua_ad;
int Dolore277;
const char *Labore0;
int Deserunt00;
const char *Velit_90;
const char *Dolor_58;
const char *Sed_41;
const char *count;
const char *next_page;
const char *previous_page;
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();
CkHttp_putBasicAuth(http,TRUE);
CkHttp_putLogin(http,"login");
CkHttp_putPassword(http,"password");
queryParams = CkJsonObject_Create();
CkJsonObject_UpdateString(queryParams,"ids","<string>");
CkJsonObject_UpdateString(queryParams,"active","<boolean>");
CkHttp_SetRequestHeader(http,"Accept","application/json");
resp = CkHttp_QuickRequestParams(http,"GET","https://example.zendesk.com/api/v2/views/show_many",queryParams);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
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(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "count": "<integer>",
// "next_page": "<string>",
// "previous_page": "<string>",
// "views": [
// {
// "active": "<boolean>",
// "conditions": {
// "amet_b2": "minim et Ut aliquip",
// "pariatur_d74": true,
// "eiusmodd7e": 16274866
// },
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "description": "<string>",
// "execution": {
// "sit_bd1": -70845421.92699432,
// "voluptated": -13477997
// },
// "id": "<integer>",
// "position": "<integer>",
// "restriction": {
// "officia_1c": -36345253.13616539
// },
// "title": "<string>",
// "updated_at": "<dateTime>"
// },
// {
// "active": "<boolean>",
// "conditions": {
// "do_99": 75108528,
// "aliqua_ad": true,
// "dolore277": 23927228,
// "labore0": "incididunt ut dolor"
// },
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "description": "<string>",
// "execution": {
// "deserunt00": 61902530,
// "velit_90": "consectetur in Excepteur"
// },
// "id": "<integer>",
// "position": "<integer>",
// "restriction": {
// "dolor_58": -88642742.97884612,
// "sed_41": "commodo ut"
// },
// "title": "<string>",
// "updated_at": "<dateTime>"
// }
// ]
// }
// 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 = CkJsonObject_stringOf(jResp,"count");
next_page = CkJsonObject_stringOf(jResp,"next_page");
previous_page = CkJsonObject_stringOf(jResp,"previous_page");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"views");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
active = CkJsonObject_stringOf(jResp,"views[i].active");
Amet_b2 = CkJsonObject_stringOf(jResp,"views[i].conditions.amet_b2");
Pariatur_d74 = CkJsonObject_BoolOf(jResp,"views[i].conditions.pariatur_d74");
Eiusmodd7e = CkJsonObject_IntOf(jResp,"views[i].conditions.eiusmodd7e");
created_at = CkJsonObject_stringOf(jResp,"views[i].created_at");
default = CkJsonObject_stringOf(jResp,"views[i].default");
description = CkJsonObject_stringOf(jResp,"views[i].description");
Sit_bd1 = CkJsonObject_stringOf(jResp,"views[i].execution.sit_bd1");
Voluptated = CkJsonObject_IntOf(jResp,"views[i].execution.voluptated");
id = CkJsonObject_stringOf(jResp,"views[i].id");
position = CkJsonObject_stringOf(jResp,"views[i].position");
Officia_1c = CkJsonObject_stringOf(jResp,"views[i].restriction.officia_1c");
title = CkJsonObject_stringOf(jResp,"views[i].title");
updated_at = CkJsonObject_stringOf(jResp,"views[i].updated_at");
Do_99 = CkJsonObject_IntOf(jResp,"views[i].conditions.do_99");
Aliqua_ad = CkJsonObject_BoolOf(jResp,"views[i].conditions.aliqua_ad");
Dolore277 = CkJsonObject_IntOf(jResp,"views[i].conditions.dolore277");
Labore0 = CkJsonObject_stringOf(jResp,"views[i].conditions.labore0");
Deserunt00 = CkJsonObject_IntOf(jResp,"views[i].execution.deserunt00");
Velit_90 = CkJsonObject_stringOf(jResp,"views[i].execution.velit_90");
Dolor_58 = CkJsonObject_stringOf(jResp,"views[i].restriction.dolor_58");
Sed_41 = CkJsonObject_stringOf(jResp,"views[i].restriction.sed_41");
i = i + 1;
}
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -u login:password -G -d "ids=%3Cstring%3E"
-d "active=%3Cboolean%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/views/show_many
Postman Collection Item JSON
{
"name": "List Views By ID",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/views/show_many?ids=<string>&active=<boolean>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"views",
"show_many"
],
"query": [
{
"key": "ids",
"value": "<string>",
"description": "(Required) List of view's ids separated by commas."
},
{
"key": "active",
"value": "<boolean>",
"description": "Only active views if true, inactive views if false"
}
]
},
"description": "#### Allowed For\n\n* Agents\n\n#### Sideloads\n\nThe following sideloads are supported:\n\n| Name | Will sideload\n| ---------------- | -------------\n| app_installation | The app installation that requires each view, if present\n| permissions | The permissions for each view\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/views/show_many?ids=<string>&active=<boolean>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"views",
"show_many"
],
"query": [
{
"key": "ids",
"value": "<string>",
"description": "(Required) List of view's ids separated by commas."
},
{
"key": "active",
"value": "<boolean>",
"description": "Only active views if true, inactive views if false"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"count\": \"<integer>\",\n \"next_page\": \"<string>\",\n \"previous_page\": \"<string>\",\n \"views\": [\n {\n \"active\": \"<boolean>\",\n \"conditions\": {\n \"amet_b2\": \"minim et Ut aliquip\",\n \"pariatur_d74\": true,\n \"eiusmodd7e\": 16274866\n },\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"execution\": {\n \"sit_bd1\": -70845421.92699432,\n \"voluptated\": -13477997\n },\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"officia_1c\": -36345253.13616539\n },\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\"\n },\n {\n \"active\": \"<boolean>\",\n \"conditions\": {\n \"do_99\": 75108528,\n \"aliqua_ad\": true,\n \"dolore277\": 23927228,\n \"labore0\": \"incididunt ut dolor\"\n },\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"execution\": {\n \"deserunt00\": 61902530,\n \"velit_90\": \"consectetur in Excepteur\"\n },\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"dolor_58\": -88642742.97884612,\n \"sed_41\": \"commodo ut\"\n },\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\"\n }\n ]\n}"
}
]
}