Chilkat Online Tools

autoit / Support API / List Views - Compact

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat_9_5_0.Http")
Local $bSuccess

$oHttp.BasicAuth = True
$oHttp.Login = "login"
$oHttp.Password = "password"

$oHttp.SetRequestHeader "Accept","application/json"

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://example.zendesk.com/api/v2/views/compact",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; 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

Local $sActive
Local $sAmet_b2
Local $bPariatur_d74
Local $iEiusmodd7e
Local $sCreated_at
Local $sDefault
Local $sDescription
Local $sSit_bd1
Local $iVoluptated
Local $sId
Local $sPosition
Local $sOfficia_1c
Local $sTitle
Local $sUpdated_at
Local $iDo_99
Local $bAliqua_ad
Local $iDolore277
Local $sLabore0
Local $iDeserunt00
Local $sVelit_90
Local $sDolor_58
Local $sSed_41

Local $sCount = $oJResp.StringOf("count")
Local $sNext_page = $oJResp.StringOf("next_page")
Local $sPrevious_page = $oJResp.StringOf("previous_page")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("views")
While $i < $iCount_i
    $oJResp.I = $i
    $sActive = $oJResp.StringOf("views[i].active")
    $sAmet_b2 = $oJResp.StringOf("views[i].conditions.amet_b2")
    $bPariatur_d74 = $oJResp.BoolOf("views[i].conditions.pariatur_d74")
    $iEiusmodd7e = $oJResp.IntOf("views[i].conditions.eiusmodd7e")
    $sCreated_at = $oJResp.StringOf("views[i].created_at")
    $sDefault = $oJResp.StringOf("views[i].default")
    $sDescription = $oJResp.StringOf("views[i].description")
    $sSit_bd1 = $oJResp.StringOf("views[i].execution.sit_bd1")
    $iVoluptated = $oJResp.IntOf("views[i].execution.voluptated")
    $sId = $oJResp.StringOf("views[i].id")
    $sPosition = $oJResp.StringOf("views[i].position")
    $sOfficia_1c = $oJResp.StringOf("views[i].restriction.officia_1c")
    $sTitle = $oJResp.StringOf("views[i].title")
    $sUpdated_at = $oJResp.StringOf("views[i].updated_at")
    $iDo_99 = $oJResp.IntOf("views[i].conditions.do_99")
    $bAliqua_ad = $oJResp.BoolOf("views[i].conditions.aliqua_ad")
    $iDolore277 = $oJResp.IntOf("views[i].conditions.dolore277")
    $sLabore0 = $oJResp.StringOf("views[i].conditions.labore0")
    $iDeserunt00 = $oJResp.IntOf("views[i].execution.deserunt00")
    $sVelit_90 = $oJResp.StringOf("views[i].execution.velit_90")
    $sDolor_58 = $oJResp.StringOf("views[i].restriction.dolor_58")
    $sSed_41 = $oJResp.StringOf("views[i].restriction.sed_41")
    $i = $i + 1
Wend

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/views/compact

Postman Collection Item JSON

{
  "name": "List Views - Compact",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/views/compact",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "views",
        "compact"
      ]
    },
    "description": "A compacted list of shared and personal views available to the current user. This endpoint never returns more than 32 records and does not respect the \"per_page\" option.\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/views/compact",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "views",
            "compact"
          ]
        }
      },
      "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}"
    }
  ]
}