Chilkat Online Tools

Foxpro / Support API / List Audits for a Ticket

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcAuthor_id
LOCAL lcCreated_at
LOCAL lcId
LOCAL lcFugiat2_
LOCAL lnAliqua4f
LOCAL lcTicket_id
LOCAL lcChannel
LOCAL lcAmet29d
LOCAL lcAliqua_b0
LOCAL lcAmet_24
LOCAL lnNon_b8
LOCAL lnIn_3a
LOCAL lnOccaecat_d98
LOCAL lnCommodo_60e
LOCAL j
LOCAL lnCount_j
LOCAL lcIn14
LOCAL lnConsequat_b9
LOCAL lnLorem4
LOCAL lcIncididunt_a
LOCAL lnIpsume1
LOCAL lcLaboris_8c
LOCAL lnConsectetur6
LOCAL lnOfficia1
LOCAL lnMinim_27
LOCAL lcUt7_2
LOCAL lcCount
LOCAL lcNext_page
LOCAL lcPrevious_page
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/tickets/:ticket_id/audits",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)

* {
*   "audits": [
*     {
*       "author_id": "<integer>",
*       "created_at": "<dateTime>",
*       "events": [
*         {
*           "in14": 98255426.2140105,
*           "consequat_b9": false,
*           "Lorem4": -18718960,
*           "incididunt_a": 91476803.94307658
*         },
*         {
*           "ipsume1": -99329065,
*           "laboris_8c": 89859673.3933256,
*           "consectetur6": true
*         }
*       ],
*       "id": "<integer>",
*       "metadata": {
*         "fugiat2_": 32930402.342455566,
*         "aliqua4f": false
*       },
*       "ticket_id": "<integer>",
*       "via": {
*         "channel": "<string>",
*         "source": {
*           "amet29d": "veniam",
*           "aliqua_b0": -53884767.66002053,
*           "amet_24": 77146472.24303994,
*           "non_b8": 30237848
*         }
*       }
*     },
*     {
*       "author_id": "<integer>",
*       "created_at": "<dateTime>",
*       "events": [
*         {
*           "officia1": true
*         },
*         {
*           "minim_27": true,
*           "Ut7_2": -37549201.88334068
*         }
*       ],
*       "id": "<integer>",
*       "metadata": {
*         "in_3a": 96878618,
*         "occaecat_d98": 24309571
*       },
*       "ticket_id": "<integer>",
*       "via": {
*         "channel": "<string>",
*         "source": {
*           "commodo_60e": true
*         }
*       }
*     }
*   ],
*   "count": "<integer>",
*   "next_page": "<string>",
*   "previous_page": "<string>"
* }

* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

lcCount = loJResp.StringOf("count")
lcNext_page = loJResp.StringOf("next_page")
lcPrevious_page = loJResp.StringOf("previous_page")
i = 0
lnCount_i = loJResp.SizeOfArray("audits")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcAuthor_id = loJResp.StringOf("audits[i].author_id")
    lcCreated_at = loJResp.StringOf("audits[i].created_at")
    lcId = loJResp.StringOf("audits[i].id")
    lcFugiat2_ = loJResp.StringOf("audits[i].metadata.fugiat2_")
    lnAliqua4f = loJResp.BoolOf("audits[i].metadata.aliqua4f")
    lcTicket_id = loJResp.StringOf("audits[i].ticket_id")
    lcChannel = loJResp.StringOf("audits[i].via.channel")
    lcAmet29d = loJResp.StringOf("audits[i].via.source.amet29d")
    lcAliqua_b0 = loJResp.StringOf("audits[i].via.source.aliqua_b0")
    lcAmet_24 = loJResp.StringOf("audits[i].via.source.amet_24")
    lnNon_b8 = loJResp.IntOf("audits[i].via.source.non_b8")
    lnIn_3a = loJResp.IntOf("audits[i].metadata.in_3a")
    lnOccaecat_d98 = loJResp.IntOf("audits[i].metadata.occaecat_d98")
    lnCommodo_60e = loJResp.BoolOf("audits[i].via.source.commodo_60e")
    j = 0
    lnCount_j = loJResp.SizeOfArray("audits[i].events")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcIn14 = loJResp.StringOf("audits[i].events[j].in14")
        lnConsequat_b9 = loJResp.BoolOf("audits[i].events[j].consequat_b9")
        lnLorem4 = loJResp.IntOf("audits[i].events[j].Lorem4")
        lcIncididunt_a = loJResp.StringOf("audits[i].events[j].incididunt_a")
        lnIpsume1 = loJResp.IntOf("audits[i].events[j].ipsume1")
        lcLaboris_8c = loJResp.StringOf("audits[i].events[j].laboris_8c")
        lnConsectetur6 = loJResp.BoolOf("audits[i].events[j].consectetur6")
        lnOfficia1 = loJResp.BoolOf("audits[i].events[j].officia1")
        lnMinim_27 = loJResp.BoolOf("audits[i].events[j].minim_27")
        lcUt7_2 = loJResp.StringOf("audits[i].events[j].Ut7_2")
        j = j + 1
    ENDDO
    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/tickets/:ticket_id/audits

Postman Collection Item JSON

{
  "name": "List Audits for a Ticket",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/tickets/:ticket_id/audits",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "tickets",
        ":ticket_id",
        "audits"
      ],
      "variable": [
        {
          "key": "ticket_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Lists the audits for a specified 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**Note**: Audits for [Archived Tickets](https://support.zendesk.com/hc/en-us/articles/4408887617050) do not support pagination for this endpoint.\n\n#### Allowed for\n\n* Agents\n"
  },
  "response": [
    {
      "name": "OK response",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/tickets/:ticket_id/audits",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "tickets",
            ":ticket_id",
            "audits"
          ],
          "variable": [
            {
              "key": "ticket_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"audits\": [\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<dateTime>\",\n      \"events\": [\n        {\n          \"in14\": 98255426.2140105,\n          \"consequat_b9\": false,\n          \"Lorem4\": -18718960,\n          \"incididunt_a\": 91476803.94307658\n        },\n        {\n          \"ipsume1\": -99329065,\n          \"laboris_8c\": 89859673.3933256,\n          \"consectetur6\": true\n        }\n      ],\n      \"id\": \"<integer>\",\n      \"metadata\": {\n        \"fugiat2_\": 32930402.342455566,\n        \"aliqua4f\": false\n      },\n      \"ticket_id\": \"<integer>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"amet29d\": \"veniam\",\n          \"aliqua_b0\": -53884767.66002053,\n          \"amet_24\": 77146472.24303994,\n          \"non_b8\": 30237848\n        }\n      }\n    },\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<dateTime>\",\n      \"events\": [\n        {\n          \"officia1\": true\n        },\n        {\n          \"minim_27\": true,\n          \"Ut7_2\": -37549201.88334068\n        }\n      ],\n      \"id\": \"<integer>\",\n      \"metadata\": {\n        \"in_3a\": 96878618,\n        \"occaecat_d98\": 24309571\n      },\n      \"ticket_id\": \"<integer>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"commodo_60e\": true\n        }\n      }\n    }\n  ],\n  \"count\": \"<integer>\",\n  \"next_page\": \"<string>\",\n  \"previous_page\": \"<string>\"\n}"
    }
  ]
}