Chilkat Online Tools

C / Support API / List Ticket Forms

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 *name;
    const char *active;
    const char *created_at;
    const char *default;
    const char *display_name;
    const char *end_user_visible;
    const char *id;
    const char *in_all_brands;
    const char *position;
    const char *raw_display_name;
    const char *raw_name;
    const char *updated_at;
    const char *url;
    int j;
    int count_j;
    int adipisicing_648;
    const char *veniamf;
    const char *id9;
    BOOL ametb8;
    const char *ut08f;
    const char *non81;
    const char *in_6b8;
    int magna1;
    int pariatur1;
    BOOL consectetur3;
    BOOL sed_6f0;
    const char *sint1d2;
    BOOL cupidatat_667;
    const char *magna_d8;
    const char *strVal;
    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,"active","<boolean>");
    CkJsonObject_UpdateString(queryParams,"end_user_visible","<boolean>");
    CkJsonObject_UpdateString(queryParams,"fallback_to_default","<boolean>");
    CkJsonObject_UpdateString(queryParams,"associated_to_brand","<boolean>");

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

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

    // {
    //   "ticket_forms": [
    //     {
    //       "name": "<string>",
    //       "active": "<boolean>",
    //       "agent_conditions": [
    //         {
    //           "adipisicing_648": -24086995
    //         },
    //         {
    //           "veniamf": "cupida"
    //         }
    //       ],
    //       "created_at": "<dateTime>",
    //       "default": "<boolean>",
    //       "display_name": "<string>",
    //       "end_user_conditions": [
    //         {
    //           "in_6b8": "Ut id",
    //           "magna1": -6245214
    //         },
    //         {
    //           "pariatur1": 67097325,
    //           "consectetur3": false,
    //           "sed_6f0": true
    //         }
    //       ],
    //       "end_user_visible": "<boolean>",
    //       "id": "<integer>",
    //       "in_all_brands": "<boolean>",
    //       "position": "<integer>",
    //       "raw_display_name": "<string>",
    //       "raw_name": "<string>",
    //       "restricted_brand_ids": [
    //         "<integer>",
    //         "<integer>"
    //       ],
    //       "ticket_field_ids": [
    //         "<integer>",
    //         "<integer>"
    //       ],
    //       "updated_at": "<dateTime>",
    //       "url": "<string>"
    //     },
    //     {
    //       "name": "<string>",
    //       "active": "<boolean>",
    //       "agent_conditions": [
    //         {
    //           "id9": "laborum veniam",
    //           "ametb8": false
    //         },
    //         {
    //           "ut08f": -79491980.10398532,
    //           "non81": "Duis est fugiat officia consequat"
    //         }
    //       ],
    //       "created_at": "<dateTime>",
    //       "default": "<boolean>",
    //       "display_name": "<string>",
    //       "end_user_conditions": [
    //         {
    //           "sint1d2": "sint ex et"
    //         },
    //         {
    //           "cupidatat_667": true,
    //           "magna_d8": 64894285.255497575
    //         }
    //       ],
    //       "end_user_visible": "<boolean>",
    //       "id": "<integer>",
    //       "in_all_brands": "<boolean>",
    //       "position": "<integer>",
    //       "raw_display_name": "<string>",
    //       "raw_name": "<string>",
    //       "restricted_brand_ids": [
    //         "<integer>",
    //         "<integer>"
    //       ],
    //       "ticket_field_ids": [
    //         "<integer>",
    //         "<integer>"
    //       ],
    //       "updated_at": "<dateTime>",
    //       "url": "<string>"
    //     }
    //   ]
    // }

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

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"ticket_forms");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        name = CkJsonObject_stringOf(jResp,"ticket_forms[i].name");
        active = CkJsonObject_stringOf(jResp,"ticket_forms[i].active");
        created_at = CkJsonObject_stringOf(jResp,"ticket_forms[i].created_at");
        default = CkJsonObject_stringOf(jResp,"ticket_forms[i].default");
        display_name = CkJsonObject_stringOf(jResp,"ticket_forms[i].display_name");
        end_user_visible = CkJsonObject_stringOf(jResp,"ticket_forms[i].end_user_visible");
        id = CkJsonObject_stringOf(jResp,"ticket_forms[i].id");
        in_all_brands = CkJsonObject_stringOf(jResp,"ticket_forms[i].in_all_brands");
        position = CkJsonObject_stringOf(jResp,"ticket_forms[i].position");
        raw_display_name = CkJsonObject_stringOf(jResp,"ticket_forms[i].raw_display_name");
        raw_name = CkJsonObject_stringOf(jResp,"ticket_forms[i].raw_name");
        updated_at = CkJsonObject_stringOf(jResp,"ticket_forms[i].updated_at");
        url = CkJsonObject_stringOf(jResp,"ticket_forms[i].url");
        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"ticket_forms[i].agent_conditions");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            adipisicing_648 = CkJsonObject_IntOf(jResp,"ticket_forms[i].agent_conditions[j].adipisicing_648");
            veniamf = CkJsonObject_stringOf(jResp,"ticket_forms[i].agent_conditions[j].veniamf");
            id9 = CkJsonObject_stringOf(jResp,"ticket_forms[i].agent_conditions[j].id9");
            ametb8 = CkJsonObject_BoolOf(jResp,"ticket_forms[i].agent_conditions[j].ametb8");
            ut08f = CkJsonObject_stringOf(jResp,"ticket_forms[i].agent_conditions[j].ut08f");
            non81 = CkJsonObject_stringOf(jResp,"ticket_forms[i].agent_conditions[j].non81");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"ticket_forms[i].end_user_conditions");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            in_6b8 = CkJsonObject_stringOf(jResp,"ticket_forms[i].end_user_conditions[j].in_6b8");
            magna1 = CkJsonObject_IntOf(jResp,"ticket_forms[i].end_user_conditions[j].magna1");
            pariatur1 = CkJsonObject_IntOf(jResp,"ticket_forms[i].end_user_conditions[j].pariatur1");
            consectetur3 = CkJsonObject_BoolOf(jResp,"ticket_forms[i].end_user_conditions[j].consectetur3");
            sed_6f0 = CkJsonObject_BoolOf(jResp,"ticket_forms[i].end_user_conditions[j].sed_6f0");
            sint1d2 = CkJsonObject_stringOf(jResp,"ticket_forms[i].end_user_conditions[j].sint1d2");
            cupidatat_667 = CkJsonObject_BoolOf(jResp,"ticket_forms[i].end_user_conditions[j].cupidatat_667");
            magna_d8 = CkJsonObject_stringOf(jResp,"ticket_forms[i].end_user_conditions[j].magna_d8");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"ticket_forms[i].restricted_brand_ids");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            strVal = CkJsonObject_stringOf(jResp,"ticket_forms[i].restricted_brand_ids[j]");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"ticket_forms[i].ticket_field_ids");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            strVal = CkJsonObject_stringOf(jResp,"ticket_forms[i].ticket_field_ids[j]");
            j = j + 1;
        }

        i = i + 1;
    }



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

    }

Curl Command

curl  -u login:password -G -d "active=%3Cboolean%3E"
	-d "end_user_visible=%3Cboolean%3E"
	-d "fallback_to_default=%3Cboolean%3E"
	-d "associated_to_brand=%3Cboolean%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms

Postman Collection Item JSON

{
  "name": "List Ticket Forms",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_forms?active=<boolean>&end_user_visible=<boolean>&fallback_to_default=<boolean>&associated_to_brand=<boolean>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_forms"
      ],
      "query": [
        {
          "key": "active",
          "value": "<boolean>",
          "description": "true returns active ticket forms; false returns inactive ticket forms. If not present, returns both"
        },
        {
          "key": "end_user_visible",
          "value": "<boolean>",
          "description": "true returns ticket forms where `end_user_visible`; false returns ticket forms that are not end-user visible. If not present, returns both"
        },
        {
          "key": "fallback_to_default",
          "value": "<boolean>",
          "description": "true returns the default ticket form when the criteria defined by the parameters results in a set without active and end-user visible ticket forms"
        },
        {
          "key": "associated_to_brand",
          "value": "<boolean>",
          "description": "true returns the ticket forms of the brand specified by the url's subdomain"
        }
      ]
    },
    "description": "Returns a list of all ticket forms for your account if accessed as an admin or agent. End users only see ticket forms that have `end_user_visible` set to true.\n\n#### Allowed For\n\n* Anyone\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/ticket_forms?active=<boolean>&end_user_visible=<boolean>&fallback_to_default=<boolean>&associated_to_brand=<boolean>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_forms"
          ],
          "query": [
            {
              "key": "active",
              "value": "<boolean>",
              "description": "true returns active ticket forms; false returns inactive ticket forms. If not present, returns both"
            },
            {
              "key": "end_user_visible",
              "value": "<boolean>",
              "description": "true returns ticket forms where `end_user_visible`; false returns ticket forms that are not end-user visible. If not present, returns both"
            },
            {
              "key": "fallback_to_default",
              "value": "<boolean>",
              "description": "true returns the default ticket form when the criteria defined by the parameters results in a set without active and end-user visible ticket forms"
            },
            {
              "key": "associated_to_brand",
              "value": "<boolean>",
              "description": "true returns the ticket forms of the brand specified by the url's subdomain"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ticket_forms\": [\n    {\n      \"name\": \"<string>\",\n      \"active\": \"<boolean>\",\n      \"agent_conditions\": [\n        {\n          \"adipisicing_648\": -24086995\n        },\n        {\n          \"veniamf\": \"cupida\"\n        }\n      ],\n      \"created_at\": \"<dateTime>\",\n      \"default\": \"<boolean>\",\n      \"display_name\": \"<string>\",\n      \"end_user_conditions\": [\n        {\n          \"in_6b8\": \"Ut id\",\n          \"magna1\": -6245214\n        },\n        {\n          \"pariatur1\": 67097325,\n          \"consectetur3\": false,\n          \"sed_6f0\": true\n        }\n      ],\n      \"end_user_visible\": \"<boolean>\",\n      \"id\": \"<integer>\",\n      \"in_all_brands\": \"<boolean>\",\n      \"position\": \"<integer>\",\n      \"raw_display_name\": \"<string>\",\n      \"raw_name\": \"<string>\",\n      \"restricted_brand_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"ticket_field_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\"\n    },\n    {\n      \"name\": \"<string>\",\n      \"active\": \"<boolean>\",\n      \"agent_conditions\": [\n        {\n          \"id9\": \"laborum veniam\",\n          \"ametb8\": false\n        },\n        {\n          \"ut08f\": -79491980.10398532,\n          \"non81\": \"Duis est fugiat officia consequat\"\n        }\n      ],\n      \"created_at\": \"<dateTime>\",\n      \"default\": \"<boolean>\",\n      \"display_name\": \"<string>\",\n      \"end_user_conditions\": [\n        {\n          \"sint1d2\": \"sint ex et\"\n        },\n        {\n          \"cupidatat_667\": true,\n          \"magna_d8\": 64894285.255497575\n        }\n      ],\n      \"end_user_visible\": \"<boolean>\",\n      \"id\": \"<integer>\",\n      \"in_all_brands\": \"<boolean>\",\n      \"position\": \"<integer>\",\n      \"raw_display_name\": \"<string>\",\n      \"raw_name\": \"<string>\",\n      \"restricted_brand_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"ticket_field_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\"\n    }\n  ]\n}"
    }
  ]
}