Swift3 / Support API / List Comments
Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
http.basicAuth = true
http.login = "login"
http.password = "password"
let queryParams = CkoJsonObject()!
queryParams.update("include_inline_images", value: "<boolean>")
queryParams.update("include", value: "<string>")
http.setRequestHeader("Accept", value: "application/json")
var resp: CkoHttpResponse? = http.quickRequestParams("GET", url: "https://example.zendesk.com/api/v2/tickets/:ticket_id/comments", json: queryParams)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "comments": [
// {
// "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": {
// "cillum_7ae": "laboris nulla fugiat",
// "sunt2": 25522168.26328881,
// "laboris__": true
// },
// "plain_body": "<string>",
// "public": "<boolean>",
// "type": "<string>",
// "uploads": [
// "<string>",
// "<string>"
// ],
// "via": {
// "channel": "<string>",
// "source": {
// "incididunt03e": false,
// "eiusmod_4": -36679297,
// "esse7": 87176441
// }
// }
// },
// {
// "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": {
// "nisi04": false
// },
// "plain_body": "<string>",
// "public": "<boolean>",
// "type": "<string>",
// "uploads": [
// "<string>",
// "<string>"
// ],
// "via": {
// "channel": "<string>",
// "source": {
// "amet__": 87553399
// }
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var audit_id: String?
var author_id: String?
var body: String?
var created_at: String?
var html_body: String?
var id: String?
var Cillum_7ae: String?
var Sunt2: String?
var Laboris__: Bool
var plain_body: String?
var v_public: String?
var v_type: String?
var Channel: String?
var Incididunt03e: Bool
var Eiusmod_4: Int
var Esse7: Int
var Nisi04: Bool
var Amet__: Int
var j: Int
var count_j: Int
var content_type: String?
var content_url: String?
var deleted: String?
var file_name: String?
var height: String?
var inline: String?
var malware_access_override: String?
var malware_scan_result: String?
var mapped_content_url: String?
var size: String?
var url: String?
var width: String?
var k: Int
var count_k: Int
var strVal: String?
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "comments").intValue
while i < count_i {
jResp.i = i
audit_id = jResp.string(of: "comments[i].audit_id")
author_id = jResp.string(of: "comments[i].author_id")
body = jResp.string(of: "comments[i].body")
created_at = jResp.string(of: "comments[i].created_at")
html_body = jResp.string(of: "comments[i].html_body")
id = jResp.string(of: "comments[i].id")
Cillum_7ae = jResp.string(of: "comments[i].metadata.cillum_7ae")
Sunt2 = jResp.string(of: "comments[i].metadata.sunt2")
Laboris__ = jResp.bool(of: "comments[i].metadata.laboris__")
plain_body = jResp.string(of: "comments[i].plain_body")
v_public = jResp.string(of: "comments[i].public")
v_type = jResp.string(of: "comments[i].type")
Channel = jResp.string(of: "comments[i].via.channel")
Incididunt03e = jResp.bool(of: "comments[i].via.source.incididunt03e")
Eiusmod_4 = jResp.int(of: "comments[i].via.source.eiusmod_4").intValue
Esse7 = jResp.int(of: "comments[i].via.source.esse7").intValue
Nisi04 = jResp.bool(of: "comments[i].metadata.nisi04")
Amet__ = jResp.int(of: "comments[i].via.source.amet__").intValue
j = 0
count_j = jResp.size(ofArray: "comments[i].attachments").intValue
while j < count_j {
jResp.j = j
content_type = jResp.string(of: "comments[i].attachments[j].content_type")
content_url = jResp.string(of: "comments[i].attachments[j].content_url")
deleted = jResp.string(of: "comments[i].attachments[j].deleted")
file_name = jResp.string(of: "comments[i].attachments[j].file_name")
height = jResp.string(of: "comments[i].attachments[j].height")
id = jResp.string(of: "comments[i].attachments[j].id")
inline = jResp.string(of: "comments[i].attachments[j].inline")
malware_access_override = jResp.string(of: "comments[i].attachments[j].malware_access_override")
malware_scan_result = jResp.string(of: "comments[i].attachments[j].malware_scan_result")
mapped_content_url = jResp.string(of: "comments[i].attachments[j].mapped_content_url")
size = jResp.string(of: "comments[i].attachments[j].size")
url = jResp.string(of: "comments[i].attachments[j].url")
width = jResp.string(of: "comments[i].attachments[j].width")
k = 0
count_k = jResp.size(ofArray: "comments[i].attachments[j].thumbnails").intValue
while k < count_k {
jResp.k = k
content_type = jResp.string(of: "comments[i].attachments[j].thumbnails[k].content_type")
content_url = jResp.string(of: "comments[i].attachments[j].thumbnails[k].content_url")
deleted = jResp.string(of: "comments[i].attachments[j].thumbnails[k].deleted")
file_name = jResp.string(of: "comments[i].attachments[j].thumbnails[k].file_name")
height = jResp.string(of: "comments[i].attachments[j].thumbnails[k].height")
id = jResp.string(of: "comments[i].attachments[j].thumbnails[k].id")
inline = jResp.string(of: "comments[i].attachments[j].thumbnails[k].inline")
malware_access_override = jResp.string(of: "comments[i].attachments[j].thumbnails[k].malware_access_override")
malware_scan_result = jResp.string(of: "comments[i].attachments[j].thumbnails[k].malware_scan_result")
mapped_content_url = jResp.string(of: "comments[i].attachments[j].thumbnails[k].mapped_content_url")
size = jResp.string(of: "comments[i].attachments[j].thumbnails[k].size")
url = jResp.string(of: "comments[i].attachments[j].thumbnails[k].url")
width = jResp.string(of: "comments[i].attachments[j].thumbnails[k].width")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "comments[i].uploads").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "comments[i].uploads[j]")
j = j + 1
}
i = i + 1
}
}
Curl Command
curl -u login:password -G -d "include_inline_images=%3Cboolean%3E"
-d "include=%3Cstring%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/tickets/:ticket_id/comments
Postman Collection Item JSON
{
"name": "List Comments",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/tickets/:ticket_id/comments?include_inline_images=<boolean>&include=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"tickets",
":ticket_id",
"comments"
],
"query": [
{
"key": "include_inline_images",
"value": "<boolean>",
"description": "Default is false. When true, inline images are also listed as attachments in the response"
},
{
"key": "include",
"value": "<string>",
"description": "Accepts \"users\". Use this parameter to list email CCs by side-loading users. Example: `?include=users`. **Note**: If the comment source is email, a deleted user will be represented as the CCd email address. If the comment source is anything else, a deleted user will be represented as the user name."
}
],
"variable": [
{
"key": "ticket_id",
"value": "<integer>"
}
]
},
"description": "Returns the comments added to the ticket.\n\nEach comment may include a `content_url` for an attachment or a `recording_url` for a voice comment that points to a file that may be hosted externally. For security reasons, take care not to inadvertently send Zendesk authentication credentials to third parties when attempting to access these files. See [Working with url properties](/documentation/ticketing/managing-tickets/working-with-url-properties).\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#### Sorting\n\nBy default, comments are sorted by creation date in ascending order.\n\nWhen using cursor pagination, use the following parameter to change the sort order:\n\n| Name | Type | Required | Comments\n| ------ | ------ | -------- | --------\n| `sort` | string | no | Possible values are \"created_at\" (ascending order) or \"-created_at\" (descending order)\n\nWhen using offset pagination, use the following parameters to change the sort order:\n\n| Name | Type | Required | Comments\n| ------------ | ------ | -------- | --------\n| `sort_order` | string | no | One of `asc`, `desc`. Defaults to `asc`\n\n#### Allowed For\n\n* Agents\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/tickets/:ticket_id/comments?include_inline_images=<boolean>&include=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"tickets",
":ticket_id",
"comments"
],
"query": [
{
"key": "include_inline_images",
"value": "<boolean>",
"description": "Default is false. When true, inline images are also listed as attachments in the response"
},
{
"key": "include",
"value": "<string>",
"description": "Accepts \"users\". Use this parameter to list email CCs by side-loading users. Example: `?include=users`. **Note**: If the comment source is email, a deleted user will be represented as the CCd email address. If the comment source is anything else, a deleted user will be represented as the user name."
}
],
"variable": [
{
"key": "ticket_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"comments\": [\n {\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 \"cillum_7ae\": \"laboris nulla fugiat\",\n \"sunt2\": 25522168.26328881,\n \"laboris__\": true\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 \"incididunt03e\": false,\n \"eiusmod_4\": -36679297,\n \"esse7\": 87176441\n }\n }\n },\n {\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 \"nisi04\": false\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 \"amet__\": 87553399\n }\n }\n }\n ]\n}"
}
]
}