Chilkat Online Tools

lianja / Support API / List Custom Roles

Back to Collection Items

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

loHttp = createobject("CkHttp")

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

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

loSbResponseBody = createobject("CkStringBuilder")
llSuccess = loHttp.QuickGetSb("https://example.zendesk.com/api/v2/custom_roles",loSbResponseBody)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loSbResponseBody
    return
endif

loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.

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

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    release loHttp
    release loSbResponseBody
    release loJResp
    return
endif

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

// {
//   "custom_roles": [
//     {
//       "name": "<string>",
//       "role_type": "<integer>",
//       "configuration": {
//         "assign_tickets_to_any_group": "<boolean>",
//         "chat_access": "<boolean>",
//         "end_user_list_access": "<string>",
//         "end_user_profile_access": "<string>",
//         "explore_access": "<string>",
//         "forum_access": "<string>",
//         "forum_access_restricted_content": "<boolean>",
//         "group_access": "<boolean>",
//         "light_agent": "<boolean>",
//         "macro_access": "<string>",
//         "manage_business_rules": "<boolean>",
//         "manage_contextual_workspaces": "<boolean>",
//         "manage_dynamic_content": "<boolean>",
//         "manage_extensions_and_channels": "<boolean>",
//         "manage_facebook": "<boolean>",
//         "manage_organization_fields": "<boolean>",
//         "manage_ticket_fields": "<boolean>",
//         "manage_ticket_forms": "<boolean>",
//         "manage_user_fields": "<boolean>",
//         "moderate_forums": "<boolean>",
//         "organization_editing": "<boolean>",
//         "organization_notes_editing": "<boolean>",
//         "report_access": "<string>",
//         "side_conversation_create": "<boolean>",
//         "ticket_access": "<string>",
//         "ticket_comment_access": "<string>",
//         "ticket_deletion": "<boolean>",
//         "ticket_editing": "<boolean>",
//         "ticket_merge": "<boolean>",
//         "ticket_tag_editing": "<boolean>",
//         "twitter_search_access": "<boolean>",
//         "user_view_access": "<string>",
//         "view_access": "<string>",
//         "view_deleted_tickets": "<boolean>",
//         "voice_access": "<boolean>",
//         "voice_dashboard_access": "<boolean>"
//       },
//       "created_at": "<dateTime>",
//       "description": "<string>",
//       "id": "<integer>",
//       "team_member_count": "<integer>",
//       "updated_at": "<dateTime>"
//     },
//     {
//       "name": "<string>",
//       "role_type": "<integer>",
//       "configuration": {
//         "assign_tickets_to_any_group": "<boolean>",
//         "chat_access": "<boolean>",
//         "end_user_list_access": "<string>",
//         "end_user_profile_access": "<string>",
//         "explore_access": "<string>",
//         "forum_access": "<string>",
//         "forum_access_restricted_content": "<boolean>",
//         "group_access": "<boolean>",
//         "light_agent": "<boolean>",
//         "macro_access": "<string>",
//         "manage_business_rules": "<boolean>",
//         "manage_contextual_workspaces": "<boolean>",
//         "manage_dynamic_content": "<boolean>",
//         "manage_extensions_and_channels": "<boolean>",
//         "manage_facebook": "<boolean>",
//         "manage_organization_fields": "<boolean>",
//         "manage_ticket_fields": "<boolean>",
//         "manage_ticket_forms": "<boolean>",
//         "manage_user_fields": "<boolean>",
//         "moderate_forums": "<boolean>",
//         "organization_editing": "<boolean>",
//         "organization_notes_editing": "<boolean>",
//         "report_access": "<string>",
//         "side_conversation_create": "<boolean>",
//         "ticket_access": "<string>",
//         "ticket_comment_access": "<string>",
//         "ticket_deletion": "<boolean>",
//         "ticket_editing": "<boolean>",
//         "ticket_merge": "<boolean>",
//         "ticket_tag_editing": "<boolean>",
//         "twitter_search_access": "<boolean>",
//         "user_view_access": "<string>",
//         "view_access": "<string>",
//         "view_deleted_tickets": "<boolean>",
//         "voice_access": "<boolean>",
//         "voice_dashboard_access": "<boolean>"
//       },
//       "created_at": "<dateTime>",
//       "description": "<string>",
//       "id": "<integer>",
//       "team_member_count": "<integer>",
//       "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

i = 0
lnCount_i = loJResp.SizeOfArray("custom_roles")
do while i < lnCount_i
    loJResp.I = i
    lcName = loJResp.StringOf("custom_roles[i].name")
    lcRole_type = loJResp.StringOf("custom_roles[i].role_type")
    lcAssign_tickets_to_any_group = loJResp.StringOf("custom_roles[i].configuration.assign_tickets_to_any_group")
    lcChat_access = loJResp.StringOf("custom_roles[i].configuration.chat_access")
    lcEnd_user_list_access = loJResp.StringOf("custom_roles[i].configuration.end_user_list_access")
    lcEnd_user_profile_access = loJResp.StringOf("custom_roles[i].configuration.end_user_profile_access")
    lcExplore_access = loJResp.StringOf("custom_roles[i].configuration.explore_access")
    lcForum_access = loJResp.StringOf("custom_roles[i].configuration.forum_access")
    lcForum_access_restricted_content = loJResp.StringOf("custom_roles[i].configuration.forum_access_restricted_content")
    lcGroup_access = loJResp.StringOf("custom_roles[i].configuration.group_access")
    lcLight_agent = loJResp.StringOf("custom_roles[i].configuration.light_agent")
    lcMacro_access = loJResp.StringOf("custom_roles[i].configuration.macro_access")
    lcManage_business_rules = loJResp.StringOf("custom_roles[i].configuration.manage_business_rules")
    lcManage_contextual_workspaces = loJResp.StringOf("custom_roles[i].configuration.manage_contextual_workspaces")
    lcManage_dynamic_content = loJResp.StringOf("custom_roles[i].configuration.manage_dynamic_content")
    lcManage_extensions_and_channels = loJResp.StringOf("custom_roles[i].configuration.manage_extensions_and_channels")
    lcManage_facebook = loJResp.StringOf("custom_roles[i].configuration.manage_facebook")
    lcManage_organization_fields = loJResp.StringOf("custom_roles[i].configuration.manage_organization_fields")
    lcManage_ticket_fields = loJResp.StringOf("custom_roles[i].configuration.manage_ticket_fields")
    lcManage_ticket_forms = loJResp.StringOf("custom_roles[i].configuration.manage_ticket_forms")
    lcManage_user_fields = loJResp.StringOf("custom_roles[i].configuration.manage_user_fields")
    lcModerate_forums = loJResp.StringOf("custom_roles[i].configuration.moderate_forums")
    lcOrganization_editing = loJResp.StringOf("custom_roles[i].configuration.organization_editing")
    lcOrganization_notes_editing = loJResp.StringOf("custom_roles[i].configuration.organization_notes_editing")
    lcReport_access = loJResp.StringOf("custom_roles[i].configuration.report_access")
    lcSide_conversation_create = loJResp.StringOf("custom_roles[i].configuration.side_conversation_create")
    lcTicket_access = loJResp.StringOf("custom_roles[i].configuration.ticket_access")
    lcTicket_comment_access = loJResp.StringOf("custom_roles[i].configuration.ticket_comment_access")
    lcTicket_deletion = loJResp.StringOf("custom_roles[i].configuration.ticket_deletion")
    lcTicket_editing = loJResp.StringOf("custom_roles[i].configuration.ticket_editing")
    lcTicket_merge = loJResp.StringOf("custom_roles[i].configuration.ticket_merge")
    lcTicket_tag_editing = loJResp.StringOf("custom_roles[i].configuration.ticket_tag_editing")
    lcTwitter_search_access = loJResp.StringOf("custom_roles[i].configuration.twitter_search_access")
    lcUser_view_access = loJResp.StringOf("custom_roles[i].configuration.user_view_access")
    lcView_access = loJResp.StringOf("custom_roles[i].configuration.view_access")
    lcView_deleted_tickets = loJResp.StringOf("custom_roles[i].configuration.view_deleted_tickets")
    lcVoice_access = loJResp.StringOf("custom_roles[i].configuration.voice_access")
    lcVoice_dashboard_access = loJResp.StringOf("custom_roles[i].configuration.voice_dashboard_access")
    lcCreated_at = loJResp.StringOf("custom_roles[i].created_at")
    lcDescription = loJResp.StringOf("custom_roles[i].description")
    lcId = loJResp.StringOf("custom_roles[i].id")
    lcTeam_member_count = loJResp.StringOf("custom_roles[i].team_member_count")
    lcUpdated_at = loJResp.StringOf("custom_roles[i].updated_at")
    i = i + 1
enddo


release loHttp
release loSbResponseBody
release loJResp

Curl Command

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

Postman Collection Item JSON

{
  "name": "List Custom Roles",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/custom_roles",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "custom_roles"
      ]
    },
    "description": "#### Availability\n\n* Accounts on the Enterprise plan or above\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/custom_roles",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "custom_roles"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"custom_roles\": [\n    {\n      \"name\": \"<string>\",\n      \"role_type\": \"<integer>\",\n      \"configuration\": {\n        \"assign_tickets_to_any_group\": \"<boolean>\",\n        \"chat_access\": \"<boolean>\",\n        \"end_user_list_access\": \"<string>\",\n        \"end_user_profile_access\": \"<string>\",\n        \"explore_access\": \"<string>\",\n        \"forum_access\": \"<string>\",\n        \"forum_access_restricted_content\": \"<boolean>\",\n        \"group_access\": \"<boolean>\",\n        \"light_agent\": \"<boolean>\",\n        \"macro_access\": \"<string>\",\n        \"manage_business_rules\": \"<boolean>\",\n        \"manage_contextual_workspaces\": \"<boolean>\",\n        \"manage_dynamic_content\": \"<boolean>\",\n        \"manage_extensions_and_channels\": \"<boolean>\",\n        \"manage_facebook\": \"<boolean>\",\n        \"manage_organization_fields\": \"<boolean>\",\n        \"manage_ticket_fields\": \"<boolean>\",\n        \"manage_ticket_forms\": \"<boolean>\",\n        \"manage_user_fields\": \"<boolean>\",\n        \"moderate_forums\": \"<boolean>\",\n        \"organization_editing\": \"<boolean>\",\n        \"organization_notes_editing\": \"<boolean>\",\n        \"report_access\": \"<string>\",\n        \"side_conversation_create\": \"<boolean>\",\n        \"ticket_access\": \"<string>\",\n        \"ticket_comment_access\": \"<string>\",\n        \"ticket_deletion\": \"<boolean>\",\n        \"ticket_editing\": \"<boolean>\",\n        \"ticket_merge\": \"<boolean>\",\n        \"ticket_tag_editing\": \"<boolean>\",\n        \"twitter_search_access\": \"<boolean>\",\n        \"user_view_access\": \"<string>\",\n        \"view_access\": \"<string>\",\n        \"view_deleted_tickets\": \"<boolean>\",\n        \"voice_access\": \"<boolean>\",\n        \"voice_dashboard_access\": \"<boolean>\"\n      },\n      \"created_at\": \"<dateTime>\",\n      \"description\": \"<string>\",\n      \"id\": \"<integer>\",\n      \"team_member_count\": \"<integer>\",\n      \"updated_at\": \"<dateTime>\"\n    },\n    {\n      \"name\": \"<string>\",\n      \"role_type\": \"<integer>\",\n      \"configuration\": {\n        \"assign_tickets_to_any_group\": \"<boolean>\",\n        \"chat_access\": \"<boolean>\",\n        \"end_user_list_access\": \"<string>\",\n        \"end_user_profile_access\": \"<string>\",\n        \"explore_access\": \"<string>\",\n        \"forum_access\": \"<string>\",\n        \"forum_access_restricted_content\": \"<boolean>\",\n        \"group_access\": \"<boolean>\",\n        \"light_agent\": \"<boolean>\",\n        \"macro_access\": \"<string>\",\n        \"manage_business_rules\": \"<boolean>\",\n        \"manage_contextual_workspaces\": \"<boolean>\",\n        \"manage_dynamic_content\": \"<boolean>\",\n        \"manage_extensions_and_channels\": \"<boolean>\",\n        \"manage_facebook\": \"<boolean>\",\n        \"manage_organization_fields\": \"<boolean>\",\n        \"manage_ticket_fields\": \"<boolean>\",\n        \"manage_ticket_forms\": \"<boolean>\",\n        \"manage_user_fields\": \"<boolean>\",\n        \"moderate_forums\": \"<boolean>\",\n        \"organization_editing\": \"<boolean>\",\n        \"organization_notes_editing\": \"<boolean>\",\n        \"report_access\": \"<string>\",\n        \"side_conversation_create\": \"<boolean>\",\n        \"ticket_access\": \"<string>\",\n        \"ticket_comment_access\": \"<string>\",\n        \"ticket_deletion\": \"<boolean>\",\n        \"ticket_editing\": \"<boolean>\",\n        \"ticket_merge\": \"<boolean>\",\n        \"ticket_tag_editing\": \"<boolean>\",\n        \"twitter_search_access\": \"<boolean>\",\n        \"user_view_access\": \"<string>\",\n        \"view_access\": \"<string>\",\n        \"view_deleted_tickets\": \"<boolean>\",\n        \"voice_access\": \"<boolean>\",\n        \"voice_dashboard_access\": \"<boolean>\"\n      },\n      \"created_at\": \"<dateTime>\",\n      \"description\": \"<string>\",\n      \"id\": \"<integer>\",\n      \"team_member_count\": \"<integer>\",\n      \"updated_at\": \"<dateTime>\"\n    }\n  ]\n}"
    }
  ]
}