PureBasic / Support API / Redact Chat Comment
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
CkHttp::setCkBasicAuth(http, 1)
CkHttp::setCkLogin(http, "login")
CkHttp::setCkPassword(http, "password")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
resp.i = CkHttp::ckQuickRequest(http,"PUT","https://example.zendesk.com/api/v2/chat_redactions/:ticket_id")
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(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
sunt_4.i
laborum4.i
tempor_2.i
laboris__b0.i
esse_6.s
veniam_1.i
in_0b.i
exercitation164.s
Id.s = CkJsonObject::ckStringOf(jResp,"chat_event.id")
v_Type.s = CkJsonObject::ckStringOf(jResp,"chat_event.type")
Chat_id.s = CkJsonObject::ckStringOf(jResp,"chat_event.value.chat_id")
Visitor_id.s = CkJsonObject::ckStringOf(jResp,"chat_event.value.visitor_id")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"chat_event.value.history")
While i < count_i
CkJsonObject::setCkI(jResp, i)
sunt_4 = CkJsonObject::ckBoolOf(jResp,"chat_event.value.history[i].sunt_4")
laborum4 = CkJsonObject::ckBoolOf(jResp,"chat_event.value.history[i].laborum4")
tempor_2 = CkJsonObject::ckBoolOf(jResp,"chat_event.value.history[i].tempor_2")
laboris__b0 = CkJsonObject::ckIntOf(jResp,"chat_event.value.history[i].laboris__b0")
esse_6 = CkJsonObject::ckStringOf(jResp,"chat_event.value.history[i].esse_6")
veniam_1 = CkJsonObject::ckIntOf(jResp,"chat_event.value.history[i].veniam_1")
in_0b = CkJsonObject::ckIntOf(jResp,"chat_event.value.history[i].in_0b")
exercitation164 = CkJsonObject::ckStringOf(jResp,"chat_event.value.history[i].exercitation164")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -u login:password -X PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/chat_redactions/:ticket_id
Postman Collection Item JSON
{
"name": "Redact Chat Comment",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/chat_redactions/:ticket_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"chat_redactions",
":ticket_id"
],
"variable": [
{
"key": "ticket_id",
"value": "<integer>"
}
]
},
"description": "Permanently removes words or strings from a chat ticket's comment. \n\nWrap `<redact>` tags around the content in the chat comment you want redacted. Example: \n\n```json\n{\n \"text\": \"My ID number is <redact>847564</redact>!\"\n}\n```\n\nThe characters contained in the tag will be replaced by the ▇ symbol.\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_index | integer | true | The `chat_index` in the `ChatMessage` event in the ticket audit. See [Ticket Audits](/api-reference/ticketing/tickets/ticket_audits) |\n| text | string | true | The `message` in the `ChatMessage` event in the ticket audit. See [Ticket Audits](/api-reference/ticketing/tickets/ticket_audits). Wrap `message` with `<redact>` tags |\n\nTo get the required body properties, make a request to the [Ticket Audit](/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\": \"ChatMessage\",\n \"message\": \"My ID number is 847564!\"\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_redactions/:ticket_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"chat_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}"
}
]
}