Chilkat Online Tools

unicodeCpp / Support API / Show Ticket Metrics

Back to Collection Items

#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    http.put_BasicAuth(true);
    http.put_Login(L"login");
    http.put_Password(L"password");

    http.SetRequestHeader(L"Accept",L"application/json");

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://example.zendesk.com/api/v2/ticket_metrics/:ticket_metric_id",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastHeader());
        wprintf(L"Failed.\n");
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "ticket_metric": [
    //     {
    //       "agent_wait_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "assigned_at": "<dateTime>",
    //       "assignee_stations": "<integer>",
    //       "assignee_updated_at": "<dateTime>",
    //       "created_at": "<dateTime>",
    //       "custom_status_updated_at": "<dateTime>",
    //       "first_resolution_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "full_resolution_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "group_stations": "<integer>",
    //       "id": "<integer>",
    //       "initially_assigned_at": "<dateTime>",
    //       "latest_comment_added_at": "<dateTime>",
    //       "on_hold_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "reopens": "<integer>",
    //       "replies": "<integer>",
    //       "reply_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "reply_time_in_seconds": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "requester_updated_at": "<dateTime>",
    //       "requester_wait_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "solved_at": "<dateTime>",
    //       "status_updated_at": "<dateTime>",
    //       "ticket_id": "<integer>",
    //       "updated_at": "<dateTime>",
    //       "url": "<string>"
    //     },
    //     {
    //       "agent_wait_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "assigned_at": "<dateTime>",
    //       "assignee_stations": "<integer>",
    //       "assignee_updated_at": "<dateTime>",
    //       "created_at": "<dateTime>",
    //       "custom_status_updated_at": "<dateTime>",
    //       "first_resolution_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "full_resolution_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "group_stations": "<integer>",
    //       "id": "<integer>",
    //       "initially_assigned_at": "<dateTime>",
    //       "latest_comment_added_at": "<dateTime>",
    //       "on_hold_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "reopens": "<integer>",
    //       "replies": "<integer>",
    //       "reply_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "reply_time_in_seconds": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "requester_updated_at": "<dateTime>",
    //       "requester_wait_time_in_minutes": {
    //         "business": "<integer>",
    //         "calendar": "<integer>"
    //       },
    //       "solved_at": "<dateTime>",
    //       "status_updated_at": "<dateTime>",
    //       "ticket_id": "<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.

    const wchar_t *Business = 0;
    const wchar_t *Calendar = 0;
    const wchar_t *assigned_at = 0;
    const wchar_t *assignee_stations = 0;
    const wchar_t *assignee_updated_at = 0;
    const wchar_t *created_at = 0;
    const wchar_t *custom_status_updated_at = 0;
    const wchar_t *first_resolution_time_in_minutesBusiness = 0;
    const wchar_t *first_resolution_time_in_minutesCalendar = 0;
    const wchar_t *full_resolution_time_in_minutesBusiness = 0;
    const wchar_t *full_resolution_time_in_minutesCalendar = 0;
    const wchar_t *group_stations = 0;
    const wchar_t *id = 0;
    const wchar_t *initially_assigned_at = 0;
    const wchar_t *latest_comment_added_at = 0;
    const wchar_t *on_hold_time_in_minutesBusiness = 0;
    const wchar_t *on_hold_time_in_minutesCalendar = 0;
    const wchar_t *reopens = 0;
    const wchar_t *replies = 0;
    const wchar_t *reply_time_in_minutesBusiness = 0;
    const wchar_t *reply_time_in_minutesCalendar = 0;
    const wchar_t *reply_time_in_secondsBusiness = 0;
    const wchar_t *reply_time_in_secondsCalendar = 0;
    const wchar_t *requester_updated_at = 0;
    const wchar_t *requester_wait_time_in_minutesBusiness = 0;
    const wchar_t *requester_wait_time_in_minutesCalendar = 0;
    const wchar_t *solved_at = 0;
    const wchar_t *status_updated_at = 0;
    const wchar_t *ticket_id = 0;
    const wchar_t *updated_at = 0;
    const wchar_t *url = 0;

    int i = 0;
    int count_i = jResp.SizeOfArray(L"ticket_metric");
    while (i < count_i) {
        jResp.put_I(i);
        Business = jResp.stringOf(L"ticket_metric[i].agent_wait_time_in_minutes.business");
        Calendar = jResp.stringOf(L"ticket_metric[i].agent_wait_time_in_minutes.calendar");
        assigned_at = jResp.stringOf(L"ticket_metric[i].assigned_at");
        assignee_stations = jResp.stringOf(L"ticket_metric[i].assignee_stations");
        assignee_updated_at = jResp.stringOf(L"ticket_metric[i].assignee_updated_at");
        created_at = jResp.stringOf(L"ticket_metric[i].created_at");
        custom_status_updated_at = jResp.stringOf(L"ticket_metric[i].custom_status_updated_at");
        first_resolution_time_in_minutesBusiness = jResp.stringOf(L"ticket_metric[i].first_resolution_time_in_minutes.business");
        first_resolution_time_in_minutesCalendar = jResp.stringOf(L"ticket_metric[i].first_resolution_time_in_minutes.calendar");
        full_resolution_time_in_minutesBusiness = jResp.stringOf(L"ticket_metric[i].full_resolution_time_in_minutes.business");
        full_resolution_time_in_minutesCalendar = jResp.stringOf(L"ticket_metric[i].full_resolution_time_in_minutes.calendar");
        group_stations = jResp.stringOf(L"ticket_metric[i].group_stations");
        id = jResp.stringOf(L"ticket_metric[i].id");
        initially_assigned_at = jResp.stringOf(L"ticket_metric[i].initially_assigned_at");
        latest_comment_added_at = jResp.stringOf(L"ticket_metric[i].latest_comment_added_at");
        on_hold_time_in_minutesBusiness = jResp.stringOf(L"ticket_metric[i].on_hold_time_in_minutes.business");
        on_hold_time_in_minutesCalendar = jResp.stringOf(L"ticket_metric[i].on_hold_time_in_minutes.calendar");
        reopens = jResp.stringOf(L"ticket_metric[i].reopens");
        replies = jResp.stringOf(L"ticket_metric[i].replies");
        reply_time_in_minutesBusiness = jResp.stringOf(L"ticket_metric[i].reply_time_in_minutes.business");
        reply_time_in_minutesCalendar = jResp.stringOf(L"ticket_metric[i].reply_time_in_minutes.calendar");
        reply_time_in_secondsBusiness = jResp.stringOf(L"ticket_metric[i].reply_time_in_seconds.business");
        reply_time_in_secondsCalendar = jResp.stringOf(L"ticket_metric[i].reply_time_in_seconds.calendar");
        requester_updated_at = jResp.stringOf(L"ticket_metric[i].requester_updated_at");
        requester_wait_time_in_minutesBusiness = jResp.stringOf(L"ticket_metric[i].requester_wait_time_in_minutes.business");
        requester_wait_time_in_minutesCalendar = jResp.stringOf(L"ticket_metric[i].requester_wait_time_in_minutes.calendar");
        solved_at = jResp.stringOf(L"ticket_metric[i].solved_at");
        status_updated_at = jResp.stringOf(L"ticket_metric[i].status_updated_at");
        ticket_id = jResp.stringOf(L"ticket_metric[i].ticket_id");
        updated_at = jResp.stringOf(L"ticket_metric[i].updated_at");
        url = jResp.stringOf(L"ticket_metric[i].url");
        i = i + 1;
    }
    }

Curl Command

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

Postman Collection Item JSON

{
  "name": "Show Ticket Metrics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_metrics/:ticket_metric_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_metrics",
        ":ticket_metric_id"
      ],
      "variable": [
        {
          "key": "ticket_metric_id",
          "value": "<string>"
        }
      ]
    },
    "description": "Returns a specific metric, or the metrics of a specific ticket.\n\n#### Pagination\n\n- Cursor pagination (recommended)\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Agents\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_metrics/:ticket_metric_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_metrics",
            ":ticket_metric_id"
          ],
          "variable": [
            {
              "key": "ticket_metric_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ticket_metric\": [\n    {\n      \"agent_wait_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"assigned_at\": \"<dateTime>\",\n      \"assignee_stations\": \"<integer>\",\n      \"assignee_updated_at\": \"<dateTime>\",\n      \"created_at\": \"<dateTime>\",\n      \"custom_status_updated_at\": \"<dateTime>\",\n      \"first_resolution_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"full_resolution_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"group_stations\": \"<integer>\",\n      \"id\": \"<integer>\",\n      \"initially_assigned_at\": \"<dateTime>\",\n      \"latest_comment_added_at\": \"<dateTime>\",\n      \"on_hold_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"reopens\": \"<integer>\",\n      \"replies\": \"<integer>\",\n      \"reply_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"reply_time_in_seconds\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"requester_updated_at\": \"<dateTime>\",\n      \"requester_wait_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"solved_at\": \"<dateTime>\",\n      \"status_updated_at\": \"<dateTime>\",\n      \"ticket_id\": \"<integer>\",\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\"\n    },\n    {\n      \"agent_wait_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"assigned_at\": \"<dateTime>\",\n      \"assignee_stations\": \"<integer>\",\n      \"assignee_updated_at\": \"<dateTime>\",\n      \"created_at\": \"<dateTime>\",\n      \"custom_status_updated_at\": \"<dateTime>\",\n      \"first_resolution_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"full_resolution_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"group_stations\": \"<integer>\",\n      \"id\": \"<integer>\",\n      \"initially_assigned_at\": \"<dateTime>\",\n      \"latest_comment_added_at\": \"<dateTime>\",\n      \"on_hold_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"reopens\": \"<integer>\",\n      \"replies\": \"<integer>\",\n      \"reply_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"reply_time_in_seconds\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"requester_updated_at\": \"<dateTime>\",\n      \"requester_wait_time_in_minutes\": {\n        \"business\": \"<integer>\",\n        \"calendar\": \"<integer>\"\n      },\n      \"solved_at\": \"<dateTime>\",\n      \"status_updated_at\": \"<dateTime>\",\n      \"ticket_id\": \"<integer>\",\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\"\n    }\n  ]\n}"
    }
  ]
}