VB.NET / Support API / Listing Comments
Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New Chilkat.Http
Dim success As Boolean
http.BasicAuth = True
http.Login = "login"
http.Password = "password"
Dim queryParams As New Chilkat.JsonObject
queryParams.UpdateString("since","<string>")
queryParams.UpdateString("role","<string>")
http.SetRequestHeader("Accept","application/json")
Dim resp As Chilkat.HttpResponse = http.QuickRequestParams("GET","https://example.zendesk.com/api/v2/requests/:request_id/comments",queryParams)
If (http.LastMethodSuccess = False) Then
Debug.WriteLine(http.LastErrorText)
Exit Sub
End If
Dim sbResponseBody As New Chilkat.StringBuilder
resp.GetBodySb(sbResponseBody)
Dim jResp As New Chilkat.JsonObject
jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False
Debug.WriteLine("Response Body:")
Debug.WriteLine(jResp.Emit())
Dim respStatusCode As Integer = resp.StatusCode
Debug.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
Debug.WriteLine("Response Header:")
Debug.WriteLine(resp.Header)
Debug.WriteLine("Failed.")
Exit Sub
End If
' 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
Dim audit_id As String
Dim author_id As String
Dim body As String
Dim created_at As String
Dim html_body As String
Dim id As String
Dim Cillum_7ae As String
Dim Sunt2 As String
Dim Laboris__ As Boolean
Dim plain_body As String
Dim v_public As String
Dim v_type As String
Dim Channel As String
Dim Incididunt03e As Boolean
Dim Eiusmod_4 As Integer
Dim Esse7 As Integer
Dim Nisi04 As Boolean
Dim Amet__ As Integer
Dim j As Integer
Dim count_j As Integer
Dim content_type As String
Dim content_url As String
Dim deleted As String
Dim file_name As String
Dim height As String
Dim inline As String
Dim malware_access_override As String
Dim malware_scan_result As String
Dim mapped_content_url As String
Dim size As String
Dim url As String
Dim width As String
Dim k As Integer
Dim count_k As Integer
Dim strVal As String
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("comments")
While i < count_i
jResp.I = i
audit_id = jResp.StringOf("comments[i].audit_id")
author_id = jResp.StringOf("comments[i].author_id")
body = jResp.StringOf("comments[i].body")
created_at = jResp.StringOf("comments[i].created_at")
html_body = jResp.StringOf("comments[i].html_body")
id = jResp.StringOf("comments[i].id")
Cillum_7ae = jResp.StringOf("comments[i].metadata.cillum_7ae")
Sunt2 = jResp.StringOf("comments[i].metadata.sunt2")
Laboris__ = jResp.BoolOf("comments[i].metadata.laboris__")
plain_body = jResp.StringOf("comments[i].plain_body")
v_public = jResp.StringOf("comments[i].public")
v_type = jResp.StringOf("comments[i].type")
Channel = jResp.StringOf("comments[i].via.channel")
Incididunt03e = jResp.BoolOf("comments[i].via.source.incididunt03e")
Eiusmod_4 = jResp.IntOf("comments[i].via.source.eiusmod_4")
Esse7 = jResp.IntOf("comments[i].via.source.esse7")
Nisi04 = jResp.BoolOf("comments[i].metadata.nisi04")
Amet__ = jResp.IntOf("comments[i].via.source.amet__")
j = 0
count_j = jResp.SizeOfArray("comments[i].attachments")
While j < count_j
jResp.J = j
content_type = jResp.StringOf("comments[i].attachments[j].content_type")
content_url = jResp.StringOf("comments[i].attachments[j].content_url")
deleted = jResp.StringOf("comments[i].attachments[j].deleted")
file_name = jResp.StringOf("comments[i].attachments[j].file_name")
height = jResp.StringOf("comments[i].attachments[j].height")
id = jResp.StringOf("comments[i].attachments[j].id")
inline = jResp.StringOf("comments[i].attachments[j].inline")
malware_access_override = jResp.StringOf("comments[i].attachments[j].malware_access_override")
malware_scan_result = jResp.StringOf("comments[i].attachments[j].malware_scan_result")
mapped_content_url = jResp.StringOf("comments[i].attachments[j].mapped_content_url")
size = jResp.StringOf("comments[i].attachments[j].size")
url = jResp.StringOf("comments[i].attachments[j].url")
width = jResp.StringOf("comments[i].attachments[j].width")
k = 0
count_k = jResp.SizeOfArray("comments[i].attachments[j].thumbnails")
While k < count_k
jResp.K = k
content_type = jResp.StringOf("comments[i].attachments[j].thumbnails[k].content_type")
content_url = jResp.StringOf("comments[i].attachments[j].thumbnails[k].content_url")
deleted = jResp.StringOf("comments[i].attachments[j].thumbnails[k].deleted")
file_name = jResp.StringOf("comments[i].attachments[j].thumbnails[k].file_name")
height = jResp.StringOf("comments[i].attachments[j].thumbnails[k].height")
id = jResp.StringOf("comments[i].attachments[j].thumbnails[k].id")
inline = jResp.StringOf("comments[i].attachments[j].thumbnails[k].inline")
malware_access_override = jResp.StringOf("comments[i].attachments[j].thumbnails[k].malware_access_override")
malware_scan_result = jResp.StringOf("comments[i].attachments[j].thumbnails[k].malware_scan_result")
mapped_content_url = jResp.StringOf("comments[i].attachments[j].thumbnails[k].mapped_content_url")
size = jResp.StringOf("comments[i].attachments[j].thumbnails[k].size")
url = jResp.StringOf("comments[i].attachments[j].thumbnails[k].url")
width = jResp.StringOf("comments[i].attachments[j].thumbnails[k].width")
k = k + 1
End While
j = j + 1
End While
j = 0
count_j = jResp.SizeOfArray("comments[i].uploads")
While j < count_j
jResp.J = j
strVal = jResp.StringOf("comments[i].uploads[j]")
j = j + 1
End While
i = i + 1
End While
Curl Command
curl -u login:password -G -d "since=%3Cstring%3E"
-d "role=%3Cstring%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/requests/:request_id/comments
Postman Collection Item JSON
{
"name": "Listing Comments",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/requests/:request_id/comments?since=<string>&role=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"requests",
":request_id",
"comments"
],
"query": [
{
"key": "since",
"value": "<string>",
"description": "Filters the comments from the given datetime"
},
{
"key": "role",
"value": "<string>",
"description": "One of \"agent\", \"end_user\". If not specified it does not filter"
}
],
"variable": [
{
"key": "request_id",
"value": "<integer>"
}
]
},
"description": "#### Pagination\n\n- Cursor pagination (recommended)\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\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_by` | string | no | One of `created_at`, `updated_at`\n| `sort_order` | string | no | One of `asc`, `desc`\n\n#### Allowed For\n\n* End Users\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/requests/:request_id/comments?since=<string>&role=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"requests",
":request_id",
"comments"
],
"query": [
{
"key": "since",
"value": "<string>",
"description": "Filters the comments from the given datetime"
},
{
"key": "role",
"value": "<string>",
"description": "One of \"agent\", \"end_user\". If not specified it does not filter"
}
],
"variable": [
{
"key": "request_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}"
}
]
}