Chilkat Online Tools

PowerBuilder / Support API / List Trigger Categories

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Active_count
string ls_Inactive_count
string ls_V_Next
string ls_Prev
string ls_After_cursor
string ls_Before_cursor
string ls_Has_more
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("page[after]","<string>")
loo_QueryParams.UpdateString("page[before]","<string>")
loo_QueryParams.UpdateString("page[size]","<integer>")
loo_QueryParams.UpdateString("sort","-updated_at")
loo_QueryParams.UpdateString("include","rule_counts")

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

loo_Resp = loo_Http.QuickRequestParams("GET","https://example.zendesk.com/api/v2/trigger_categories",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

// {
//   "trigger_categories": [
//     {
//       "active_count": "<long>",
//       "inactive_count": "<long>"
//     },
//     {
//       "active_count": "<long>",
//       "inactive_count": "<long>"
//     }
//   ],
//   "links": {
//     "next": "<string>",
//     "prev": "<string>"
//   },
//   "meta": {
//     "after_cursor": "<string>",
//     "before_cursor": "<string>",
//     "has_more": "<boolean>"
//   }
// }

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

ls_V_Next = loo_JResp.StringOf("links.next")
ls_Prev = loo_JResp.StringOf("links.prev")
ls_After_cursor = loo_JResp.StringOf("meta.after_cursor")
ls_Before_cursor = loo_JResp.StringOf("meta.before_cursor")
ls_Has_more = loo_JResp.StringOf("meta.has_more")
i = 0
li_Count_i = loo_JResp.SizeOfArray("trigger_categories")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Active_count = loo_JResp.StringOf("trigger_categories[i].active_count")
    ls_Inactive_count = loo_JResp.StringOf("trigger_categories[i].inactive_count")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl  -u login:password -G -d "page[after]=%3Cstring%3E"
	-d "page[before]=%3Cstring%3E"
	-d "page[size]=%3Cinteger%3E"
	-d "sort=-updated_at"
	-d "include=rule_counts"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/trigger_categories

Postman Collection Item JSON

{
  "name": "List Trigger Categories",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "trigger_categories"
      ],
      "query": [
        {
          "key": "page[after]",
          "value": "<string>",
          "description": "Pagination parameters"
        },
        {
          "key": "page[before]",
          "value": "<string>",
          "description": "Pagination parameters"
        },
        {
          "key": "page[size]",
          "value": "<integer>",
          "description": "Pagination parameters"
        },
        {
          "key": "sort",
          "value": "-updated_at",
          "description": "Sort parameters"
        },
        {
          "key": "include",
          "value": "rule_counts",
          "description": "Allowed sideloads"
        }
      ]
    },
    "description": "Returns all the trigger categories in the account."
  },
  "response": [
    {
      "name": "A paged array of trigger categories",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"trigger_categories\": [\n    {\n      \"active_count\": \"<long>\",\n      \"inactive_count\": \"<long>\"\n    },\n    {\n      \"active_count\": \"<long>\",\n      \"inactive_count\": \"<long>\"\n    }\n  ],\n  \"links\": {\n    \"next\": \"<string>\",\n    \"prev\": \"<string>\"\n  },\n  \"meta\": {\n    \"after_cursor\": \"<string>\",\n    \"before_cursor\": \"<string>\",\n    \"has_more\": \"<boolean>\"\n  }\n}"
    },
    {
      "name": "Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    },\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    }\n  ]\n}"
    },
    {
      "name": "Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/trigger_categories?page[after]=<string>&page[before]=<string>&page[size]=<integer>&sort=-updated_at&include=rule_counts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "trigger_categories"
          ],
          "query": [
            {
              "key": "page[after]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[before]",
              "value": "<string>",
              "description": "Pagination parameters"
            },
            {
              "key": "page[size]",
              "value": "<integer>",
              "description": "Pagination parameters"
            },
            {
              "key": "sort",
              "value": "-updated_at",
              "description": "Sort parameters"
            },
            {
              "key": "include",
              "value": "rule_counts",
              "description": "Allowed sideloads"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    },\n    {\n      \"code\": \"<string>\",\n      \"title\": \"<string>\",\n      \"detail\": \"<string>\",\n      \"id\": \"<string>\",\n      \"links\": {},\n      \"source\": {},\n      \"status\": \"<string>\"\n    }\n  ]\n}"
    }
  ]
}