Chilkat Online Tools

unicodeC / Support API / Show Ticket Form

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 *aliqua6;
    const wchar_t *Lorem_d;
    int mollit_cf;
    const wchar_t *ullamco_f7;
    const wchar_t *consequate_;
    int consectetur_00;
    const wchar_t *laborum50;
    BOOL irure__c;
    const wchar_t *Excepteur_38;
    const wchar_t *sunt_8;
    const wchar_t *nulla_48;
    const wchar_t *ullamco_f6;
    const wchar_t *strVal;
    const wchar_t *Name;
    const wchar_t *Active;
    const wchar_t *Created_at;
    const wchar_t *Default;
    const wchar_t *Display_name;
    const wchar_t *End_user_visible;
    const wchar_t *Id;
    const wchar_t *In_all_brands;
    const wchar_t *Position;
    const wchar_t *Raw_display_name;
    const wchar_t *Raw_name;
    const wchar_t *Updated_at;
    const wchar_t *v_Url;
    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();

    CkHttpW_putBasicAuth(http,TRUE);
    CkHttpW_putLogin(http,L"login");
    CkHttpW_putPassword(http,L"password");

    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://example.zendesk.com/api/v2/ticket_forms/:ticket_form_id",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)

    // {
    //   "ticket_form": {
    //     "name": "<string>",
    //     "active": "<boolean>",
    //     "agent_conditions": [
    //       {
    //         "aliqua6": "proident deserunt",
    //         "Lorem_d": "cillum dolor Excepteur ut",
    //         "mollit_cf": -33059877,
    //         "ullamco_f7": "dolore occaeca"
    //       },
    //       {
    //         "consequate_": 29214347.18513973,
    //         "consectetur_00": 83697330,
    //         "laborum50": "cillum Ut"
    //       }
    //     ],
    //     "created_at": "<dateTime>",
    //     "default": "<boolean>",
    //     "display_name": "<string>",
    //     "end_user_conditions": [
    //       {
    //         "irure__c": false,
    //         "Excepteur_38": -15203265.607602075,
    //         "sunt_8": "culpa laboris Ut"
    //       },
    //       {
    //         "nulla_48": "quis esse",
    //         "ullamco_f6": -25516091.19614251
    //       }
    //     ],
    //     "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.

    Name = CkJsonObjectW_stringOf(jResp,L"ticket_form.name");
    Active = CkJsonObjectW_stringOf(jResp,L"ticket_form.active");
    Created_at = CkJsonObjectW_stringOf(jResp,L"ticket_form.created_at");
    Default = CkJsonObjectW_stringOf(jResp,L"ticket_form.default");
    Display_name = CkJsonObjectW_stringOf(jResp,L"ticket_form.display_name");
    End_user_visible = CkJsonObjectW_stringOf(jResp,L"ticket_form.end_user_visible");
    Id = CkJsonObjectW_stringOf(jResp,L"ticket_form.id");
    In_all_brands = CkJsonObjectW_stringOf(jResp,L"ticket_form.in_all_brands");
    Position = CkJsonObjectW_stringOf(jResp,L"ticket_form.position");
    Raw_display_name = CkJsonObjectW_stringOf(jResp,L"ticket_form.raw_display_name");
    Raw_name = CkJsonObjectW_stringOf(jResp,L"ticket_form.raw_name");
    Updated_at = CkJsonObjectW_stringOf(jResp,L"ticket_form.updated_at");
    v_Url = CkJsonObjectW_stringOf(jResp,L"ticket_form.url");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"ticket_form.agent_conditions");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        aliqua6 = CkJsonObjectW_stringOf(jResp,L"ticket_form.agent_conditions[i].aliqua6");
        Lorem_d = CkJsonObjectW_stringOf(jResp,L"ticket_form.agent_conditions[i].Lorem_d");
        mollit_cf = CkJsonObjectW_IntOf(jResp,L"ticket_form.agent_conditions[i].mollit_cf");
        ullamco_f7 = CkJsonObjectW_stringOf(jResp,L"ticket_form.agent_conditions[i].ullamco_f7");
        consequate_ = CkJsonObjectW_stringOf(jResp,L"ticket_form.agent_conditions[i].consequate_");
        consectetur_00 = CkJsonObjectW_IntOf(jResp,L"ticket_form.agent_conditions[i].consectetur_00");
        laborum50 = CkJsonObjectW_stringOf(jResp,L"ticket_form.agent_conditions[i].laborum50");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"ticket_form.end_user_conditions");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        irure__c = CkJsonObjectW_BoolOf(jResp,L"ticket_form.end_user_conditions[i].irure__c");
        Excepteur_38 = CkJsonObjectW_stringOf(jResp,L"ticket_form.end_user_conditions[i].Excepteur_38");
        sunt_8 = CkJsonObjectW_stringOf(jResp,L"ticket_form.end_user_conditions[i].sunt_8");
        nulla_48 = CkJsonObjectW_stringOf(jResp,L"ticket_form.end_user_conditions[i].nulla_48");
        ullamco_f6 = CkJsonObjectW_stringOf(jResp,L"ticket_form.end_user_conditions[i].ullamco_f6");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"ticket_form.restricted_brand_ids");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        strVal = CkJsonObjectW_stringOf(jResp,L"ticket_form.restricted_brand_ids[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"ticket_form.ticket_field_ids");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        strVal = CkJsonObjectW_stringOf(jResp,L"ticket_form.ticket_field_ids[i]");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms/:ticket_form_id

Postman Collection Item JSON

{
  "name": "Show Ticket Form",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_forms/:ticket_form_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_forms",
        ":ticket_form_id"
      ],
      "variable": [
        {
          "key": "ticket_form_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "#### Allowed For\n\n* Admins, Agents, and End Users\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/:ticket_form_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_forms",
            ":ticket_form_id"
          ],
          "variable": [
            {
              "key": "ticket_form_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ticket_form\": {\n    \"name\": \"<string>\",\n    \"active\": \"<boolean>\",\n    \"agent_conditions\": [\n      {\n        \"aliqua6\": \"proident deserunt\",\n        \"Lorem_d\": \"cillum dolor Excepteur ut\",\n        \"mollit_cf\": -33059877,\n        \"ullamco_f7\": \"dolore occaeca\"\n      },\n      {\n        \"consequate_\": 29214347.18513973,\n        \"consectetur_00\": 83697330,\n        \"laborum50\": \"cillum Ut\"\n      }\n    ],\n    \"created_at\": \"<dateTime>\",\n    \"default\": \"<boolean>\",\n    \"display_name\": \"<string>\",\n    \"end_user_conditions\": [\n      {\n        \"irure__c\": false,\n        \"Excepteur_38\": -15203265.607602075,\n        \"sunt_8\": \"culpa laboris Ut\"\n      },\n      {\n        \"nulla_48\": \"quis esse\",\n        \"ullamco_f6\": -25516091.19614251\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}"
    }
  ]
}