Chilkat Online Tools

C / Support API / List Trigger Categories

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_count;
    const char *inactive_count;
    const char *v_Next;
    const char *Prev;
    const char *After_cursor;
    const char *Before_cursor;
    const char *Has_more;
    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,"page[after]","<string>");
    CkJsonObject_UpdateString(queryParams,"page[before]","<string>");
    CkJsonObject_UpdateString(queryParams,"page[size]","<integer>");
    CkJsonObject_UpdateString(queryParams,"sort","-updated_at");
    CkJsonObject_UpdateString(queryParams,"include","rule_counts");

    CkHttp_SetRequestHeader(http,"Accept","application/json");

    resp = CkHttp_QuickRequestParams(http,"GET","https://example.zendesk.com/api/v2/trigger_categories",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)

    // {
    //   "trigger_categories": [
    //     {
    //       "active_count": "<long>",
    //       "inactive_count": "<long>"
    //     },
    //     {
    //       "active_count": "<long>",
    //       "inactive_count": "<long>"
    //     }
    //   ],
    //   "links": {
    //     "next": "<string>",
    //     "prev": "<string>"
    //   },
    //   "meta": {
    //     "after_cursor": "<string>",
    //     "before_cursor": "<string>",
    //     "has_more": "<boolean>"
    //   }
    // }

    // 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.

    v_Next = CkJsonObject_stringOf(jResp,"links.next");
    Prev = CkJsonObject_stringOf(jResp,"links.prev");
    After_cursor = CkJsonObject_stringOf(jResp,"meta.after_cursor");
    Before_cursor = CkJsonObject_stringOf(jResp,"meta.before_cursor");
    Has_more = CkJsonObject_stringOf(jResp,"meta.has_more");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"trigger_categories");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        active_count = CkJsonObject_stringOf(jResp,"trigger_categories[i].active_count");
        inactive_count = CkJsonObject_stringOf(jResp,"trigger_categories[i].inactive_count");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl  -u login:password -G -d "page[after]=%3Cstring%3E"
	-d "page[before]=%3Cstring%3E"
	-d "page[size]=%3Cinteger%3E"
	-d "sort=-updated_at"
	-d "include=rule_counts"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/trigger_categories

Postman Collection Item JSON

{
  "name": "List Trigger Categories",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "trigger_categories"
      ],
      "query": [
        {
          "key": "page[after]",
          "value": "<string>",
          "description": "Pagination parameters"
        },
        {
          "key": "page[before]",
          "value": "<string>",
          "description": "Pagination parameters"
        },
        {
          "key": "page[size]",
          "value": "<integer>",
          "description": "Pagination parameters"
        },
        {
          "key": "sort",
          "value": "-updated_at",
          "description": "Sort parameters"
        },
        {
          "key": "include",
          "value": "rule_counts",
          "description": "Allowed sideloads"
        }
      ]
    },
    "description": "Returns all the trigger categories in the account."
  },
  "response": [
    {
      "name": "A paged array of trigger categories",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"trigger_categories\": [\n    {\n      \"active_count\": \"<long>\",\n      \"inactive_count\": \"<long>\"\n    },\n    {\n      \"active_count\": \"<long>\",\n      \"inactive_count\": \"<long>\"\n    }\n  ],\n  \"links\": {\n    \"next\": \"<string>\",\n    \"prev\": \"<string>\"\n  },\n  \"meta\": {\n    \"after_cursor\": \"<string>\",\n    \"before_cursor\": \"<string>\",\n    \"has_more\": \"<boolean>\"\n  }\n}"
    },
    {
      "name": "Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    },\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    }\n  ]\n}"
    },
    {
      "name": "Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    },\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    }\n  ]\n}"
    }
  ]
}