Chilkat Online Tools

Foxpro / Support API / List Ticket Metrics

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcBusiness
LOCAL lcCalendar
LOCAL lcAssigned_at
LOCAL lcAssignee_stations
LOCAL lcAssignee_updated_at
LOCAL lcCreated_at
LOCAL lcCustom_status_updated_at
LOCAL lcFirst_resolution_time_in_minutesBusiness
LOCAL lcFirst_resolution_time_in_minutesCalendar
LOCAL lcFull_resolution_time_in_minutesBusiness
LOCAL lcFull_resolution_time_in_minutesCalendar
LOCAL lcGroup_stations
LOCAL lcId
LOCAL lcInitially_assigned_at
LOCAL lcLatest_comment_added_at
LOCAL lcOn_hold_time_in_minutesBusiness
LOCAL lcOn_hold_time_in_minutesCalendar
LOCAL lcReopens
LOCAL lcReplies
LOCAL lcReply_time_in_minutesBusiness
LOCAL lcReply_time_in_minutesCalendar
LOCAL lcReply_time_in_secondsBusiness
LOCAL lcReply_time_in_secondsCalendar
LOCAL lcRequester_updated_at
LOCAL lcRequester_wait_time_in_minutesBusiness
LOCAL lcRequester_wait_time_in_minutesCalendar
LOCAL lcSolved_at
LOCAL lcStatus_updated_at
LOCAL lcTicket_id
LOCAL lcUpdated_at
LOCAL lcUrl
LOCAL i
LOCAL lnCount_i

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

loHttp.BasicAuth = 1
loHttp.Login = "login"
loHttp.Password = "password"

loHttp.SetRequestHeader("Accept","application/json")

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://example.zendesk.com/api/v2/ticket_metrics",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

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

* {
*   "ticket_metrics": [
*     {
*       "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

i = 0
lnCount_i = loJResp.SizeOfArray("ticket_metrics")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcBusiness = loJResp.StringOf("ticket_metrics[i].agent_wait_time_in_minutes.business")
    lcCalendar = loJResp.StringOf("ticket_metrics[i].agent_wait_time_in_minutes.calendar")
    lcAssigned_at = loJResp.StringOf("ticket_metrics[i].assigned_at")
    lcAssignee_stations = loJResp.StringOf("ticket_metrics[i].assignee_stations")
    lcAssignee_updated_at = loJResp.StringOf("ticket_metrics[i].assignee_updated_at")
    lcCreated_at = loJResp.StringOf("ticket_metrics[i].created_at")
    lcCustom_status_updated_at = loJResp.StringOf("ticket_metrics[i].custom_status_updated_at")
    lcFirst_resolution_time_in_minutesBusiness = loJResp.StringOf("ticket_metrics[i].first_resolution_time_in_minutes.business")
    lcFirst_resolution_time_in_minutesCalendar = loJResp.StringOf("ticket_metrics[i].first_resolution_time_in_minutes.calendar")
    lcFull_resolution_time_in_minutesBusiness = loJResp.StringOf("ticket_metrics[i].full_resolution_time_in_minutes.business")
    lcFull_resolution_time_in_minutesCalendar = loJResp.StringOf("ticket_metrics[i].full_resolution_time_in_minutes.calendar")
    lcGroup_stations = loJResp.StringOf("ticket_metrics[i].group_stations")
    lcId = loJResp.StringOf("ticket_metrics[i].id")
    lcInitially_assigned_at = loJResp.StringOf("ticket_metrics[i].initially_assigned_at")
    lcLatest_comment_added_at = loJResp.StringOf("ticket_metrics[i].latest_comment_added_at")
    lcOn_hold_time_in_minutesBusiness = loJResp.StringOf("ticket_metrics[i].on_hold_time_in_minutes.business")
    lcOn_hold_time_in_minutesCalendar = loJResp.StringOf("ticket_metrics[i].on_hold_time_in_minutes.calendar")
    lcReopens = loJResp.StringOf("ticket_metrics[i].reopens")
    lcReplies = loJResp.StringOf("ticket_metrics[i].replies")
    lcReply_time_in_minutesBusiness = loJResp.StringOf("ticket_metrics[i].reply_time_in_minutes.business")
    lcReply_time_in_minutesCalendar = loJResp.StringOf("ticket_metrics[i].reply_time_in_minutes.calendar")
    lcReply_time_in_secondsBusiness = loJResp.StringOf("ticket_metrics[i].reply_time_in_seconds.business")
    lcReply_time_in_secondsCalendar = loJResp.StringOf("ticket_metrics[i].reply_time_in_seconds.calendar")
    lcRequester_updated_at = loJResp.StringOf("ticket_metrics[i].requester_updated_at")
    lcRequester_wait_time_in_minutesBusiness = loJResp.StringOf("ticket_metrics[i].requester_wait_time_in_minutes.business")
    lcRequester_wait_time_in_minutesCalendar = loJResp.StringOf("ticket_metrics[i].requester_wait_time_in_minutes.calendar")
    lcSolved_at = loJResp.StringOf("ticket_metrics[i].solved_at")
    lcStatus_updated_at = loJResp.StringOf("ticket_metrics[i].status_updated_at")
    lcTicket_id = loJResp.StringOf("ticket_metrics[i].ticket_id")
    lcUpdated_at = loJResp.StringOf("ticket_metrics[i].updated_at")
    lcUrl = loJResp.StringOf("ticket_metrics[i].url")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

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

Postman Collection Item JSON

{
  "name": "List Ticket Metrics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_metrics",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_metrics"
      ]
    },
    "description": "Returns a list of tickets with their metrics.\n\nTickets are ordered chronologically by created date, from newest to oldest.\nThe last ticket listed may not be the absolute oldest ticket in your account\ndue to ticket archiving.\n\nArchived tickets are not included in the response. See\n[About archived tickets](https://support.zendesk.com/hc/en-us/articles/203657756) in\nZendesk help.\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\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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_metrics"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ticket_metrics\": [\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}"
    }
  ]
}