Chilkat Online Tools

PowerBuilder / Support API / List Audits for a Ticket

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Author_id
string ls_Created_at
string ls_Id
string ls_Fugiat2_
integer li_Aliqua4f
string ls_Ticket_id
string ls_Channel
string ls_Amet29d
string ls_Aliqua_b0
string ls_Amet_24
integer li_Non_b8
integer li_In_3a
integer li_Occaecat_d98
integer li_Commodo_60e
integer j
integer li_Count_j
string ls_In14
integer li_Consequat_b9
integer li_Lorem4
string ls_Incididunt_a
integer li_Ipsume1
string ls_Laboris_8c
integer li_Consectetur6
integer li_Officia1
integer li_Minim_27
string ls_Ut7_2
string ls_Count
string ls_Next_page
string ls_Previous_page
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

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

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://example.zendesk.com/api/v2/tickets/:ticket_id/audits",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

ls_Count = loo_JResp.StringOf("count")
ls_Next_page = loo_JResp.StringOf("next_page")
ls_Previous_page = loo_JResp.StringOf("previous_page")
i = 0
li_Count_i = loo_JResp.SizeOfArray("audits")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Author_id = loo_JResp.StringOf("audits[i].author_id")
    ls_Created_at = loo_JResp.StringOf("audits[i].created_at")
    ls_Id = loo_JResp.StringOf("audits[i].id")
    ls_Fugiat2_ = loo_JResp.StringOf("audits[i].metadata.fugiat2_")
    li_Aliqua4f = loo_JResp.BoolOf("audits[i].metadata.aliqua4f")
    ls_Ticket_id = loo_JResp.StringOf("audits[i].ticket_id")
    ls_Channel = loo_JResp.StringOf("audits[i].via.channel")
    ls_Amet29d = loo_JResp.StringOf("audits[i].via.source.amet29d")
    ls_Aliqua_b0 = loo_JResp.StringOf("audits[i].via.source.aliqua_b0")
    ls_Amet_24 = loo_JResp.StringOf("audits[i].via.source.amet_24")
    li_Non_b8 = loo_JResp.IntOf("audits[i].via.source.non_b8")
    li_In_3a = loo_JResp.IntOf("audits[i].metadata.in_3a")
    li_Occaecat_d98 = loo_JResp.IntOf("audits[i].metadata.occaecat_d98")
    li_Commodo_60e = loo_JResp.BoolOf("audits[i].via.source.commodo_60e")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("audits[i].events")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_In14 = loo_JResp.StringOf("audits[i].events[j].in14")
        li_Consequat_b9 = loo_JResp.BoolOf("audits[i].events[j].consequat_b9")
        li_Lorem4 = loo_JResp.IntOf("audits[i].events[j].Lorem4")
        ls_Incididunt_a = loo_JResp.StringOf("audits[i].events[j].incididunt_a")
        li_Ipsume1 = loo_JResp.IntOf("audits[i].events[j].ipsume1")
        ls_Laboris_8c = loo_JResp.StringOf("audits[i].events[j].laboris_8c")
        li_Consectetur6 = loo_JResp.BoolOf("audits[i].events[j].consectetur6")
        li_Officia1 = loo_JResp.BoolOf("audits[i].events[j].officia1")
        li_Minim_27 = loo_JResp.BoolOf("audits[i].events[j].minim_27")
        ls_Ut7_2 = loo_JResp.StringOf("audits[i].events[j].Ut7_2")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

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}"
    }
  ]
}