Chilkat Online Tools

VB6 / Support API / List Views By ID

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 ChilkatHttp
Dim success As Long

http.BasicAuth = 1
http.Login = "login"
http.Password = "password"

Dim queryParams As New ChilkatJsonObject
success = queryParams.UpdateString("ids","<string>")
success = queryParams.UpdateString("active","<boolean>")

http.SetRequestHeader "Accept","application/json"

Dim resp As ChilkatHttpResponse
Set resp = http.QuickRequestParams("GET","https://example.zendesk.com/api/v2/views/show_many",queryParams)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim sbResponseBody As New ChilkatStringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = resp.StatusCode
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print resp.Header
    Debug.Print "Failed."

    Exit Sub
End If

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

' {
'   "count": "<integer>",
'   "next_page": "<string>",
'   "previous_page": "<string>",
'   "views": [
'     {
'       "active": "<boolean>",
'       "conditions": {
'         "amet_b2": "minim et Ut aliquip",
'         "pariatur_d74": true,
'         "eiusmodd7e": 16274866
'       },
'       "created_at": "<dateTime>",
'       "default": "<boolean>",
'       "description": "<string>",
'       "execution": {
'         "sit_bd1": -70845421.92699432,
'         "voluptated": -13477997
'       },
'       "id": "<integer>",
'       "position": "<integer>",
'       "restriction": {
'         "officia_1c": -36345253.13616539
'       },
'       "title": "<string>",
'       "updated_at": "<dateTime>"
'     },
'     {
'       "active": "<boolean>",
'       "conditions": {
'         "do_99": 75108528,
'         "aliqua_ad": true,
'         "dolore277": 23927228,
'         "labore0": "incididunt ut dolor"
'       },
'       "created_at": "<dateTime>",
'       "default": "<boolean>",
'       "description": "<string>",
'       "execution": {
'         "deserunt00": 61902530,
'         "velit_90": "consectetur in Excepteur"
'       },
'       "id": "<integer>",
'       "position": "<integer>",
'       "restriction": {
'         "dolor_58": -88642742.97884612,
'         "sed_41": "commodo ut"
'       },
'       "title": "<string>",
'       "updated_at": "<dateTime>"
'     }
'   ]
' }

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

Dim active As String
Dim Amet_b2 As String
Dim Pariatur_d74 As Long
Dim Eiusmodd7e As Long
Dim created_at As String
Dim default As String
Dim description As String
Dim Sit_bd1 As String
Dim Voluptated As Long
Dim id As String
Dim position As String
Dim Officia_1c As String
Dim title As String
Dim updated_at As String
Dim Do_99 As Long
Dim Aliqua_ad As Long
Dim Dolore277 As Long
Dim Labore0 As String
Dim Deserunt00 As Long
Dim Velit_90 As String
Dim Dolor_58 As String
Dim Sed_41 As String

Dim count As String
count = jResp.StringOf("count")
Dim next_page As String
next_page = jResp.StringOf("next_page")
Dim previous_page As String
previous_page = jResp.StringOf("previous_page")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("views")
Do While i < count_i
    jResp.I = i
    active = jResp.StringOf("views[i].active")
    Amet_b2 = jResp.StringOf("views[i].conditions.amet_b2")
    Pariatur_d74 = jResp.BoolOf("views[i].conditions.pariatur_d74")
    Eiusmodd7e = jResp.IntOf("views[i].conditions.eiusmodd7e")
    created_at = jResp.StringOf("views[i].created_at")
    default = jResp.StringOf("views[i].default")
    description = jResp.StringOf("views[i].description")
    Sit_bd1 = jResp.StringOf("views[i].execution.sit_bd1")
    Voluptated = jResp.IntOf("views[i].execution.voluptated")
    id = jResp.StringOf("views[i].id")
    position = jResp.StringOf("views[i].position")
    Officia_1c = jResp.StringOf("views[i].restriction.officia_1c")
    title = jResp.StringOf("views[i].title")
    updated_at = jResp.StringOf("views[i].updated_at")
    Do_99 = jResp.IntOf("views[i].conditions.do_99")
    Aliqua_ad = jResp.BoolOf("views[i].conditions.aliqua_ad")
    Dolore277 = jResp.IntOf("views[i].conditions.dolore277")
    Labore0 = jResp.StringOf("views[i].conditions.labore0")
    Deserunt00 = jResp.IntOf("views[i].execution.deserunt00")
    Velit_90 = jResp.StringOf("views[i].execution.velit_90")
    Dolor_58 = jResp.StringOf("views[i].restriction.dolor_58")
    Sed_41 = jResp.StringOf("views[i].restriction.sed_41")
    i = i + 1
Loop

Curl Command

curl  -u login:password -G -d "ids=%3Cstring%3E"
	-d "active=%3Cboolean%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/views/show_many

Postman Collection Item JSON

{
  "name": "List Views By ID",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/views/show_many?ids=<string>&active=<boolean>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "views",
        "show_many"
      ],
      "query": [
        {
          "key": "ids",
          "value": "<string>",
          "description": "(Required) List of view's ids separated by commas."
        },
        {
          "key": "active",
          "value": "<boolean>",
          "description": "Only active views if true, inactive views if false"
        }
      ]
    },
    "description": "#### Allowed For\n\n* Agents\n\n#### Sideloads\n\nThe following sideloads are supported:\n\n| Name             | Will sideload\n| ---------------- | -------------\n| app_installation | The app installation that requires each view, if present\n| permissions      | The permissions for each view\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/views/show_many?ids=<string>&active=<boolean>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "views",
            "show_many"
          ],
          "query": [
            {
              "key": "ids",
              "value": "<string>",
              "description": "(Required) List of view's ids separated by commas."
            },
            {
              "key": "active",
              "value": "<boolean>",
              "description": "Only active views if true, inactive views if false"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"count\": \"<integer>\",\n  \"next_page\": \"<string>\",\n  \"previous_page\": \"<string>\",\n  \"views\": [\n    {\n      \"active\": \"<boolean>\",\n      \"conditions\": {\n        \"amet_b2\": \"minim et Ut aliquip\",\n        \"pariatur_d74\": true,\n        \"eiusmodd7e\": 16274866\n      },\n      \"created_at\": \"<dateTime>\",\n      \"default\": \"<boolean>\",\n      \"description\": \"<string>\",\n      \"execution\": {\n        \"sit_bd1\": -70845421.92699432,\n        \"voluptated\": -13477997\n      },\n      \"id\": \"<integer>\",\n      \"position\": \"<integer>\",\n      \"restriction\": {\n        \"officia_1c\": -36345253.13616539\n      },\n      \"title\": \"<string>\",\n      \"updated_at\": \"<dateTime>\"\n    },\n    {\n      \"active\": \"<boolean>\",\n      \"conditions\": {\n        \"do_99\": 75108528,\n        \"aliqua_ad\": true,\n        \"dolore277\": 23927228,\n        \"labore0\": \"incididunt ut dolor\"\n      },\n      \"created_at\": \"<dateTime>\",\n      \"default\": \"<boolean>\",\n      \"description\": \"<string>\",\n      \"execution\": {\n        \"deserunt00\": 61902530,\n        \"velit_90\": \"consectetur in Excepteur\"\n      },\n      \"id\": \"<integer>\",\n      \"position\": \"<integer>\",\n      \"restriction\": {\n        \"dolor_58\": -88642742.97884612,\n        \"sed_41\": \"commodo ut\"\n      },\n      \"title\": \"<string>\",\n      \"updated_at\": \"<dateTime>\"\n    }\n  ]\n}"
    }
  ]
}