Chilkat Online Tools

Foxpro / Support API / List Active Views

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcActive
LOCAL lcAmet_b2
LOCAL lnPariatur_d74
LOCAL lnEiusmodd7e
LOCAL lcCreated_at
LOCAL lcDefault
LOCAL lcDescription
LOCAL lcSit_bd1
LOCAL lnVoluptated
LOCAL lcId
LOCAL lcPosition
LOCAL lcOfficia_1c
LOCAL lcTitle
LOCAL lcUpdated_at
LOCAL lnDo_99
LOCAL lnAliqua_ad
LOCAL lnDolore277
LOCAL lcLabore0
LOCAL lnDeserunt00
LOCAL lcVelit_90
LOCAL lcDolor_58
LOCAL lcSed_41
LOCAL lcCount
LOCAL lcNext_page
LOCAL lcPrevious_page
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

loQueryParams = CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams.UpdateString("access","<string>")
loQueryParams.UpdateString("group_id","<integer>")
loQueryParams.UpdateString("sort_by","<string>")
loQueryParams.UpdateString("sort_order","<string>")

loHttp.SetRequestHeader("Accept","application/json")

loResp = loHttp.QuickRequestParams("GET","https://example.zendesk.com/api/v2/views/active",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loQueryParams
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loQueryParams
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcCount = loJResp.StringOf("count")
lcNext_page = loJResp.StringOf("next_page")
lcPrevious_page = loJResp.StringOf("previous_page")
i = 0
lnCount_i = loJResp.SizeOfArray("views")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcActive = loJResp.StringOf("views[i].active")
    lcAmet_b2 = loJResp.StringOf("views[i].conditions.amet_b2")
    lnPariatur_d74 = loJResp.BoolOf("views[i].conditions.pariatur_d74")
    lnEiusmodd7e = loJResp.IntOf("views[i].conditions.eiusmodd7e")
    lcCreated_at = loJResp.StringOf("views[i].created_at")
    lcDefault = loJResp.StringOf("views[i].default")
    lcDescription = loJResp.StringOf("views[i].description")
    lcSit_bd1 = loJResp.StringOf("views[i].execution.sit_bd1")
    lnVoluptated = loJResp.IntOf("views[i].execution.voluptated")
    lcId = loJResp.StringOf("views[i].id")
    lcPosition = loJResp.StringOf("views[i].position")
    lcOfficia_1c = loJResp.StringOf("views[i].restriction.officia_1c")
    lcTitle = loJResp.StringOf("views[i].title")
    lcUpdated_at = loJResp.StringOf("views[i].updated_at")
    lnDo_99 = loJResp.IntOf("views[i].conditions.do_99")
    lnAliqua_ad = loJResp.BoolOf("views[i].conditions.aliqua_ad")
    lnDolore277 = loJResp.IntOf("views[i].conditions.dolore277")
    lcLabore0 = loJResp.StringOf("views[i].conditions.labore0")
    lnDeserunt00 = loJResp.IntOf("views[i].execution.deserunt00")
    lcVelit_90 = loJResp.StringOf("views[i].execution.velit_90")
    lcDolor_58 = loJResp.StringOf("views[i].restriction.dolor_58")
    lcSed_41 = loJResp.StringOf("views[i].restriction.sed_41")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl  -u login:password -G -d "access=%3Cstring%3E"
	-d "group_id=%3Cinteger%3E"
	-d "sort_by=%3Cstring%3E"
	-d "sort_order=%3Cstring%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/views/active

Postman Collection Item JSON

{
  "name": "List Active Views",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/views/active?access=<string>&group_id=<integer>&sort_by=<string>&sort_order=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "views",
        "active"
      ],
      "query": [
        {
          "key": "access",
          "value": "<string>",
          "description": "Only views with given access. May be \"personal\", \"shared\", or \"account\""
        },
        {
          "key": "group_id",
          "value": "<integer>",
          "description": "Only views belonging to given group"
        },
        {
          "key": "sort_by",
          "value": "<string>",
          "description": "Possible values are \"alphabetical\", \"created_at\", or \"updated_at\". Defaults to \"position\""
        },
        {
          "key": "sort_order",
          "value": "<string>",
          "description": "One of \"asc\" or \"desc\". Defaults to \"asc\" for alphabetical and position sort, \"desc\" for all others"
        }
      ]
    },
    "description": "Lists active shared and personal views available to the current user.\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\n#### Pagination\n\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\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/active?access=<string>&group_id=<integer>&sort_by=<string>&sort_order=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "views",
            "active"
          ],
          "query": [
            {
              "key": "access",
              "value": "<string>",
              "description": "Only views with given access. May be \"personal\", \"shared\", or \"account\""
            },
            {
              "key": "group_id",
              "value": "<integer>",
              "description": "Only views belonging to given group"
            },
            {
              "key": "sort_by",
              "value": "<string>",
              "description": "Possible values are \"alphabetical\", \"created_at\", or \"updated_at\". Defaults to \"position\""
            },
            {
              "key": "sort_order",
              "value": "<string>",
              "description": "One of \"asc\" or \"desc\". Defaults to \"asc\" for alphabetical and position sort, \"desc\" for all others"
            }
          ]
        }
      },
      "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}"
    }
  ]
}