Chilkat Online Tools

C / Support API / Redact Chat Comment Attachment

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    BOOL sunt_4;
    BOOL laborum4;
    BOOL tempor_2;
    int laboris__b0;
    const char *esse_6;
    int veniam_1;
    int in_0b;
    const char *exercitation164;
    const char *Id;
    const char *v_Type;
    const char *Chat_id;
    const char *Visitor_id;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    CkHttp_putBasicAuth(http,TRUE);
    CkHttp_putLogin(http,"login");
    CkHttp_putPassword(http,"password");

    CkHttp_SetRequestHeader(http,"Accept","application/json");

    resp = CkHttp_QuickRequest(http,"PUT","https://example.zendesk.com/api/v2/chat_file_redactions/:ticket_id");
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        return;
    }

    sbResponseBody = CkStringBuilder_Create();
    CkHttpResponse_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttpResponse_getStatusCode(resp);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        printf("Failed.\n");
        CkHttpResponse_Dispose(resp);
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

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

    // {
    //   "chat_event": {
    //     "id": "<integer>",
    //     "type": "<string>",
    //     "value": {
    //       "chat_id": "<string>",
    //       "history": [
    //         {
    //           "sunt_4": false,
    //           "laborum4": false,
    //           "tempor_2": true
    //         },
    //         {
    //           "laboris__b0": 51519808,
    //           "esse_6": "labore elit",
    //           "veniam_1": 65652007,
    //           "in_0b": 13721436,
    //           "exercitation164": 83149154.88991535
    //         }
    //       ],
    //       "visitor_id": "<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.

    Id = CkJsonObject_stringOf(jResp,"chat_event.id");
    v_Type = CkJsonObject_stringOf(jResp,"chat_event.type");
    Chat_id = CkJsonObject_stringOf(jResp,"chat_event.value.chat_id");
    Visitor_id = CkJsonObject_stringOf(jResp,"chat_event.value.visitor_id");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"chat_event.value.history");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        sunt_4 = CkJsonObject_BoolOf(jResp,"chat_event.value.history[i].sunt_4");
        laborum4 = CkJsonObject_BoolOf(jResp,"chat_event.value.history[i].laborum4");
        tempor_2 = CkJsonObject_BoolOf(jResp,"chat_event.value.history[i].tempor_2");
        laboris__b0 = CkJsonObject_IntOf(jResp,"chat_event.value.history[i].laboris__b0");
        esse_6 = CkJsonObject_stringOf(jResp,"chat_event.value.history[i].esse_6");
        veniam_1 = CkJsonObject_IntOf(jResp,"chat_event.value.history[i].veniam_1");
        in_0b = CkJsonObject_IntOf(jResp,"chat_event.value.history[i].in_0b");
        exercitation164 = CkJsonObject_stringOf(jResp,"chat_event.value.history[i].exercitation164");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

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

Postman Collection Item JSON

{
  "name": "Redact Chat Comment Attachment",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/chat_file_redactions/:ticket_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "chat_file_redactions",
        ":ticket_id"
      ],
      "variable": [
        {
          "key": "ticket_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Permanently removes one or more chat attachments from a chat ticket.\n\n**Note**: This does not work on active chats. For chat tickets that predate March 2020, consider using [Redact Ticket Comment In Agent Workspace](#redact-ticket-comment-in-agent-workspace).\n\n#### Allowed For\n\n- Agents\n\n[Agent Workspace](https://support.zendesk.com/hc/en-us/articles/360024218473) must enabled for the account. Deleting tickets must be enabled for agents.\n\n#### Request Body Properties\n\n| Name         | Type    | Required | Description                                                                                                                                          |\n| ------------ | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |\n| chat_id      | string  | true     | The `chat_id` in the `ChatStartedEvent` event in the ticket audit. See [Ticket Audits](/api-reference/ticketing/tickets/ticket_audits)               |\n| chat_indexes | array   | true     | The array of `chat_index` in the `ChatFileAttachment` event in the ticket audit. See [Ticket Audits](/api-reference/ticketing/tickets/ticket_audits) |\n\nTo get the required body properties, make a request to the [Ticket Audits](/api-reference/ticketing/tickets/ticket_audits) endpoint. Example response:\n\n```http\nStatus 200 OK\n{\n  \"audits\": [\n    \"events\": [\n      {\n        \"id\": 1932802680168,\n        \"type\": \"ChatStartedEvent\",\n        \"value\": {\n          \"visitor_id\": \"10502823-16EkM3T6VNq7KMd\",\n          \"chat_id\": \"2109.10502823.Sjuj2YrBpXwei\",\n          \"history\": [\n            {\n              \"chat_index\": 0,\n              \"type\": \"ChatFileAttachment\",\n              \"filename\": \"image1.jpg\"\n            },\n            {\n              \"chat_index\": 1,\n              \"type\": \"ChatFileAttachment\",\n              \"filename\": \"image2.jpg\"\n            }\n          ]\n        }\n      }\n    ]\n  ]\n}\n```\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/chat_file_redactions/:ticket_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "chat_file_redactions",
            ":ticket_id"
          ],
          "variable": [
            {
              "key": "ticket_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"chat_event\": {\n    \"id\": \"<integer>\",\n    \"type\": \"<string>\",\n    \"value\": {\n      \"chat_id\": \"<string>\",\n      \"history\": [\n        {\n          \"sunt_4\": false,\n          \"laborum4\": false,\n          \"tempor_2\": true\n        },\n        {\n          \"laboris__b0\": 51519808,\n          \"esse_6\": \"labore elit\",\n          \"veniam_1\": 65652007,\n          \"in_0b\": 13721436,\n          \"exercitation164\": 83149154.88991535\n        }\n      ],\n      \"visitor_id\": \"<string>\"\n    }\n  }\n}"
    }
  ]
}