Chilkat Online Tools

DataFlex / Support API / Redact String in Comment

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sContent_type
    String sContent_url
    String sDeleted
    String sFile_name
    String sHeight
    String sId
    String sInline
    String sMalware_access_override
    String sMalware_scan_result
    String sMapped_content_url
    String sSize
    String sUrl
    String sWidth
    Integer j
    Integer iCount_j
    String sStrVal
    String sAudit_id
    String sAuthor_id
    String sBody
    String sCreated_at
    String sHtml_body
    String sId
    String sAliquipf9_
    String sPlain_body
    String sV_Public
    String sV_Type
    String sChannel
    Integer iMollit8
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "login"
    Set ComPassword Of hoHttp To "password"

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get ComQuickRequest Of hoHttp "PUT" "https://example.zendesk.com/api/v2/tickets/:ticket_id/comments/:ticket_comment_id/redact" To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    // {
    //   "comment": {
    //     "attachments": [
    //       {
    //         "content_type": "<string>",
    //         "content_url": "<string>",
    //         "deleted": "<boolean>",
    //         "file_name": "<string>",
    //         "height": "<string>",
    //         "id": "<integer>",
    //         "inline": "<boolean>",
    //         "malware_access_override": "<boolean>",
    //         "malware_scan_result": "<string>",
    //         "mapped_content_url": "<string>",
    //         "size": "<integer>",
    //         "url": "<string>",
    //         "width": "<string>",
    //         "thumbnails": [
    //           {
    //             "content_type": "<string>",
    //             "content_url": "<string>",
    //             "deleted": "<boolean>",
    //             "file_name": "<string>",
    //             "height": "<string>",
    //             "id": "<integer>",
    //             "inline": "<boolean>",
    //             "malware_access_override": "<boolean>",
    //             "malware_scan_result": "<string>",
    //             "mapped_content_url": "<string>",
    //             "size": "<integer>",
    //             "url": "<string>",
    //             "width": "<string>"
    //           },
    //           {
    //             "content_type": "<string>",
    //             "content_url": "<string>",
    //             "deleted": "<boolean>",
    //             "file_name": "<string>",
    //             "height": "<string>",
    //             "id": "<integer>",
    //             "inline": "<boolean>",
    //             "malware_access_override": "<boolean>",
    //             "malware_scan_result": "<string>",
    //             "mapped_content_url": "<string>",
    //             "size": "<integer>",
    //             "url": "<string>",
    //             "width": "<string>"
    //           }
    //         ]
    //       },
    //       {
    //         "content_type": "<string>",
    //         "content_url": "<string>",
    //         "deleted": "<boolean>",
    //         "file_name": "<string>",
    //         "height": "<string>",
    //         "id": "<integer>",
    //         "inline": "<boolean>",
    //         "malware_access_override": "<boolean>",
    //         "malware_scan_result": "<string>",
    //         "mapped_content_url": "<string>",
    //         "size": "<integer>",
    //         "url": "<string>",
    //         "width": "<string>",
    //         "thumbnails": [
    //           {
    //             "content_type": "<string>",
    //             "content_url": "<string>",
    //             "deleted": "<boolean>",
    //             "file_name": "<string>",
    //             "height": "<string>",
    //             "id": "<integer>",
    //             "inline": "<boolean>",
    //             "malware_access_override": "<boolean>",
    //             "malware_scan_result": "<string>",
    //             "mapped_content_url": "<string>",
    //             "size": "<integer>",
    //             "url": "<string>",
    //             "width": "<string>"
    //           },
    //           {
    //             "content_type": "<string>",
    //             "content_url": "<string>",
    //             "deleted": "<boolean>",
    //             "file_name": "<string>",
    //             "height": "<string>",
    //             "id": "<integer>",
    //             "inline": "<boolean>",
    //             "malware_access_override": "<boolean>",
    //             "malware_scan_result": "<string>",
    //             "mapped_content_url": "<string>",
    //             "size": "<integer>",
    //             "url": "<string>",
    //             "width": "<string>"
    //           }
    //         ]
    //       }
    //     ],
    //     "audit_id": "<integer>",
    //     "author_id": "<integer>",
    //     "body": "<string>",
    //     "created_at": "<dateTime>",
    //     "html_body": "<string>",
    //     "id": "<integer>",
    //     "metadata": {
    //       "aliquipf9_": 29396975.17451787
    //     },
    //     "plain_body": "<string>",
    //     "public": "<boolean>",
    //     "type": "<string>",
    //     "uploads": [
    //       "<string>",
    //       "<string>"
    //     ],
    //     "via": {
    //       "channel": "<string>",
    //       "source": {
    //         "mollit8": -84219258
    //       }
    //     }
    //   }
    // }

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

    Get ComStringOf Of hoJResp "comment.audit_id" To sAudit_id
    Get ComStringOf Of hoJResp "comment.author_id" To sAuthor_id
    Get ComStringOf Of hoJResp "comment.body" To sBody
    Get ComStringOf Of hoJResp "comment.created_at" To sCreated_at
    Get ComStringOf Of hoJResp "comment.html_body" To sHtml_body
    Get ComStringOf Of hoJResp "comment.id" To sId
    Get ComStringOf Of hoJResp "comment.metadata.aliquipf9_" To sAliquipf9_
    Get ComStringOf Of hoJResp "comment.plain_body" To sPlain_body
    Get ComStringOf Of hoJResp "comment.public" To sV_Public
    Get ComStringOf Of hoJResp "comment.type" To sV_Type
    Get ComStringOf Of hoJResp "comment.via.channel" To sChannel
    Get ComIntOf Of hoJResp "comment.via.source.mollit8" To iMollit8
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "comment.attachments" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "comment.attachments[i].content_type" To sContent_type
        Get ComStringOf Of hoJResp "comment.attachments[i].content_url" To sContent_url
        Get ComStringOf Of hoJResp "comment.attachments[i].deleted" To sDeleted
        Get ComStringOf Of hoJResp "comment.attachments[i].file_name" To sFile_name
        Get ComStringOf Of hoJResp "comment.attachments[i].height" To sHeight
        Get ComStringOf Of hoJResp "comment.attachments[i].id" To sId
        Get ComStringOf Of hoJResp "comment.attachments[i].inline" To sInline
        Get ComStringOf Of hoJResp "comment.attachments[i].malware_access_override" To sMalware_access_override
        Get ComStringOf Of hoJResp "comment.attachments[i].malware_scan_result" To sMalware_scan_result
        Get ComStringOf Of hoJResp "comment.attachments[i].mapped_content_url" To sMapped_content_url
        Get ComStringOf Of hoJResp "comment.attachments[i].size" To sSize
        Get ComStringOf Of hoJResp "comment.attachments[i].url" To sUrl
        Get ComStringOf Of hoJResp "comment.attachments[i].width" To sWidth
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "comment.attachments[i].thumbnails" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].content_type" To sContent_type
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].content_url" To sContent_url
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].deleted" To sDeleted
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].file_name" To sFile_name
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].height" To sHeight
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].id" To sId
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].inline" To sInline
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].malware_access_override" To sMalware_access_override
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].malware_scan_result" To sMalware_scan_result
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].mapped_content_url" To sMapped_content_url
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].size" To sSize
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].url" To sUrl
            Get ComStringOf Of hoJResp "comment.attachments[i].thumbnails[j].width" To sWidth
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "comment.uploads" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "comment.uploads[i]" To sStrVal
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

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

Postman Collection Item JSON

{
  "name": "Redact String in Comment",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/tickets/:ticket_id/comments/:ticket_comment_id/redact",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "tickets",
        ":ticket_id",
        "comments",
        ":ticket_comment_id",
        "redact"
      ],
      "variable": [
        {
          "key": "ticket_id",
          "value": "<integer>"
        },
        {
          "key": "ticket_comment_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Permanently removes words or strings from a ticket comment. Specify the string to redact in an object with a `text` property. Example: `'{\"text\": \"987-65-4320\"}'`. The characters of the word or string are replaced by the ▇ symbol.\n\nIf the comment was made by email, the endpoint also attempts to redact the string from the original email retained by Zendesk for audit purposes.\n\n**Note**: If you use the rich text editor, support for redacting formatted text (bold, italics, hyperlinks) is limited.\n\nRedaction is permanent. You can't undo the redaction or see *what* was removed. Once a ticket is closed, you can no longer redact strings from its comments.\n\nTo use this endpoint, the \"Agents can delete tickets\" option must be enabled in the Zendesk Support admin interface at **Admin** > **Settings** > **Agents**.\n\n#### Allowed For\n\n* Agents\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/tickets/:ticket_id/comments/:ticket_comment_id/redact",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "tickets",
            ":ticket_id",
            "comments",
            ":ticket_comment_id",
            "redact"
          ],
          "variable": [
            {
              "key": "ticket_id"
            },
            {
              "key": "ticket_comment_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"comment\": {\n    \"attachments\": [\n      {\n        \"content_type\": \"<string>\",\n        \"content_url\": \"<string>\",\n        \"deleted\": \"<boolean>\",\n        \"file_name\": \"<string>\",\n        \"height\": \"<string>\",\n        \"id\": \"<integer>\",\n        \"inline\": \"<boolean>\",\n        \"malware_access_override\": \"<boolean>\",\n        \"malware_scan_result\": \"<string>\",\n        \"mapped_content_url\": \"<string>\",\n        \"size\": \"<integer>\",\n        \"url\": \"<string>\",\n        \"width\": \"<string>\",\n        \"thumbnails\": [\n          {\n            \"content_type\": \"<string>\",\n            \"content_url\": \"<string>\",\n            \"deleted\": \"<boolean>\",\n            \"file_name\": \"<string>\",\n            \"height\": \"<string>\",\n            \"id\": \"<integer>\",\n            \"inline\": \"<boolean>\",\n            \"malware_access_override\": \"<boolean>\",\n            \"malware_scan_result\": \"<string>\",\n            \"mapped_content_url\": \"<string>\",\n            \"size\": \"<integer>\",\n            \"url\": \"<string>\",\n            \"width\": \"<string>\"\n          },\n          {\n            \"content_type\": \"<string>\",\n            \"content_url\": \"<string>\",\n            \"deleted\": \"<boolean>\",\n            \"file_name\": \"<string>\",\n            \"height\": \"<string>\",\n            \"id\": \"<integer>\",\n            \"inline\": \"<boolean>\",\n            \"malware_access_override\": \"<boolean>\",\n            \"malware_scan_result\": \"<string>\",\n            \"mapped_content_url\": \"<string>\",\n            \"size\": \"<integer>\",\n            \"url\": \"<string>\",\n            \"width\": \"<string>\"\n          }\n        ]\n      },\n      {\n        \"content_type\": \"<string>\",\n        \"content_url\": \"<string>\",\n        \"deleted\": \"<boolean>\",\n        \"file_name\": \"<string>\",\n        \"height\": \"<string>\",\n        \"id\": \"<integer>\",\n        \"inline\": \"<boolean>\",\n        \"malware_access_override\": \"<boolean>\",\n        \"malware_scan_result\": \"<string>\",\n        \"mapped_content_url\": \"<string>\",\n        \"size\": \"<integer>\",\n        \"url\": \"<string>\",\n        \"width\": \"<string>\",\n        \"thumbnails\": [\n          {\n            \"content_type\": \"<string>\",\n            \"content_url\": \"<string>\",\n            \"deleted\": \"<boolean>\",\n            \"file_name\": \"<string>\",\n            \"height\": \"<string>\",\n            \"id\": \"<integer>\",\n            \"inline\": \"<boolean>\",\n            \"malware_access_override\": \"<boolean>\",\n            \"malware_scan_result\": \"<string>\",\n            \"mapped_content_url\": \"<string>\",\n            \"size\": \"<integer>\",\n            \"url\": \"<string>\",\n            \"width\": \"<string>\"\n          },\n          {\n            \"content_type\": \"<string>\",\n            \"content_url\": \"<string>\",\n            \"deleted\": \"<boolean>\",\n            \"file_name\": \"<string>\",\n            \"height\": \"<string>\",\n            \"id\": \"<integer>\",\n            \"inline\": \"<boolean>\",\n            \"malware_access_override\": \"<boolean>\",\n            \"malware_scan_result\": \"<string>\",\n            \"mapped_content_url\": \"<string>\",\n            \"size\": \"<integer>\",\n            \"url\": \"<string>\",\n            \"width\": \"<string>\"\n          }\n        ]\n      }\n    ],\n    \"audit_id\": \"<integer>\",\n    \"author_id\": \"<integer>\",\n    \"body\": \"<string>\",\n    \"created_at\": \"<dateTime>\",\n    \"html_body\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"metadata\": {\n      \"aliquipf9_\": 29396975.17451787\n    },\n    \"plain_body\": \"<string>\",\n    \"public\": \"<boolean>\",\n    \"type\": \"<string>\",\n    \"uploads\": [\n      \"<string>\",\n      \"<string>\"\n    ],\n    \"via\": {\n      \"channel\": \"<string>\",\n      \"source\": {\n        \"mollit8\": -84219258\n      }\n    }\n  }\n}"
    }
  ]
}