Chilkat Online Tools

unicodeC / Support API / List All Ticket Audits

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW queryParams;
    HCkHttpResponseW resp;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *author_id;
    const wchar_t *created_at;
    const wchar_t *id;
    const wchar_t *Aute__;
    const wchar_t *Ex_ae;
    const wchar_t *ticket_id;
    const wchar_t *Channel;
    int Et_c59;
    const wchar_t *Veniam_689;
    const wchar_t *Elit_2ab;
    const wchar_t *Sint490;
    int j;
    int count_j;
    const wchar_t *voluptate_edf;
    int dolor0;
    BOOL sedb2;
    const wchar_t *nostrud_fd6;
    const wchar_t *ullamcoe;
    BOOL adipisicing_1;
    const wchar_t *after_cursor;
    const wchar_t *after_url;
    const wchar_t *before_cursor;
    const wchar_t *before_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");

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(queryParams,L"limit",L"<integer>");

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

    resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://example.zendesk.com/api/v2/ticket_audits",queryParams);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilderW_Create();
    CkHttpResponseW_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

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

    respStatusCode = CkHttpResponseW_getStatusCode(resp);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpResponseW_header(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

    CkHttpResponseW_Dispose(resp);

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

    // {
    //   "after_cursor": "<string>",
    //   "after_url": "<string>",
    //   "audits": [
    //     {
    //       "author_id": "<integer>",
    //       "created_at": "<dateTime>",
    //       "events": [
    //         {
    //           "voluptate_edf": 37194901.82832828,
    //           "dolor0": 61753613
    //         },
    //         {
    //           "sedb2": false
    //         }
    //       ],
    //       "id": "<integer>",
    //       "metadata": {
    //         "aute__": "proident aute qui culpa",
    //         "ex_ae": "dolore Lorem labore ut"
    //       },
    //       "ticket_id": "<integer>",
    //       "via": {
    //         "channel": "<string>",
    //         "source": {
    //           "et_c59": 68912889
    //         }
    //       }
    //     },
    //     {
    //       "author_id": "<integer>",
    //       "created_at": "<dateTime>",
    //       "events": [
    //         {
    //           "nostrud_fd6": -68241256.05178377
    //         },
    //         {
    //           "ullamcoe": "ad",
    //           "adipisicing_1": false
    //         }
    //       ],
    //       "id": "<integer>",
    //       "metadata": {
    //         "veniam_689": -18333948.100650415,
    //         "elit_2ab": "eu dolor deserunt consequat dolore"
    //       },
    //       "ticket_id": "<integer>",
    //       "via": {
    //         "channel": "<string>",
    //         "source": {
    //           "sint490": -68016605.99205834
    //         }
    //       }
    //     }
    //   ],
    //   "before_cursor": "<string>",
    //   "before_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.

    after_cursor = CkJsonObjectW_stringOf(jResp,L"after_cursor");
    after_url = CkJsonObjectW_stringOf(jResp,L"after_url");
    before_cursor = CkJsonObjectW_stringOf(jResp,L"before_cursor");
    before_url = CkJsonObjectW_stringOf(jResp,L"before_url");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"audits");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        author_id = CkJsonObjectW_stringOf(jResp,L"audits[i].author_id");
        created_at = CkJsonObjectW_stringOf(jResp,L"audits[i].created_at");
        id = CkJsonObjectW_stringOf(jResp,L"audits[i].id");
        Aute__ = CkJsonObjectW_stringOf(jResp,L"audits[i].metadata.aute__");
        Ex_ae = CkJsonObjectW_stringOf(jResp,L"audits[i].metadata.ex_ae");
        ticket_id = CkJsonObjectW_stringOf(jResp,L"audits[i].ticket_id");
        Channel = CkJsonObjectW_stringOf(jResp,L"audits[i].via.channel");
        Et_c59 = CkJsonObjectW_IntOf(jResp,L"audits[i].via.source.et_c59");
        Veniam_689 = CkJsonObjectW_stringOf(jResp,L"audits[i].metadata.veniam_689");
        Elit_2ab = CkJsonObjectW_stringOf(jResp,L"audits[i].metadata.elit_2ab");
        Sint490 = CkJsonObjectW_stringOf(jResp,L"audits[i].via.source.sint490");
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"audits[i].events");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            voluptate_edf = CkJsonObjectW_stringOf(jResp,L"audits[i].events[j].voluptate_edf");
            dolor0 = CkJsonObjectW_IntOf(jResp,L"audits[i].events[j].dolor0");
            sedb2 = CkJsonObjectW_BoolOf(jResp,L"audits[i].events[j].sedb2");
            nostrud_fd6 = CkJsonObjectW_stringOf(jResp,L"audits[i].events[j].nostrud_fd6");
            ullamcoe = CkJsonObjectW_stringOf(jResp,L"audits[i].events[j].ullamcoe");
            adipisicing_1 = CkJsonObjectW_BoolOf(jResp,L"audits[i].events[j].adipisicing_1");
            j = j + 1;
        }

        i = i + 1;
    }



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

    }

Curl Command

curl  -u login:password -G -d "limit=%3Cinteger%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_audits

Postman Collection Item JSON

{
  "name": "List All Ticket Audits",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_audits?limit=<integer>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_audits"
      ],
      "query": [
        {
          "key": "limit",
          "value": "<integer>",
          "description": "Maximum number of results returned"
        }
      ]
    },
    "description": "Returns ticket audits. Archived tickets are not included in the response. Use the [List Audits for a Ticket](#list-audits-for-a-ticket) endpoint to \nretrieve audit records for an archived ticket. To learn more about archived tickets, see [About archived tickets](https://support.zendesk.com/hc/en-us/articles/203657756).\n\nThis endpoint should not be used for capturing change data. When continually chasing the tail of a cursor, some records will be skipped. For this use case, use the [Incremental Ticket Event Export API](/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-event-export).\n\n#### Pagination\n\n- Cursor pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Admins\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_audits?limit=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_audits"
          ],
          "query": [
            {
              "key": "limit",
              "value": "<integer>",
              "description": "Maximum number of results returned"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"after_cursor\": \"<string>\",\n  \"after_url\": \"<string>\",\n  \"audits\": [\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<dateTime>\",\n      \"events\": [\n        {\n          \"voluptate_edf\": 37194901.82832828,\n          \"dolor0\": 61753613\n        },\n        {\n          \"sedb2\": false\n        }\n      ],\n      \"id\": \"<integer>\",\n      \"metadata\": {\n        \"aute__\": \"proident aute qui culpa\",\n        \"ex_ae\": \"dolore Lorem labore ut\"\n      },\n      \"ticket_id\": \"<integer>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"et_c59\": 68912889\n        }\n      }\n    },\n    {\n      \"author_id\": \"<integer>\",\n      \"created_at\": \"<dateTime>\",\n      \"events\": [\n        {\n          \"nostrud_fd6\": -68241256.05178377\n        },\n        {\n          \"ullamcoe\": \"ad\",\n          \"adipisicing_1\": false\n        }\n      ],\n      \"id\": \"<integer>\",\n      \"metadata\": {\n        \"veniam_689\": -18333948.100650415,\n        \"elit_2ab\": \"eu dolor deserunt consequat dolore\"\n      },\n      \"ticket_id\": \"<integer>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"sint490\": -68016605.99205834\n        }\n      }\n    }\n  ],\n  \"before_cursor\": \"<string>\",\n  \"before_url\": \"<string>\"\n}"
    }
  ]
}