PureBasic / Support API / List Custom Roles
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
CkHttp::setCkBasicAuth(http, 1)
CkHttp::setCkLogin(http, "login")
CkHttp::setCkPassword(http, "password")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://example.zendesk.com/api/v2/custom_roles",sbResponseBody)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttp::ckLastStatus(http)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttp::ckLastHeader(http)
Debug "Failed."
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
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
name.s
role_type.s
Assign_tickets_to_any_group.s
Chat_access.s
End_user_list_access.s
End_user_profile_access.s
Explore_access.s
Forum_access.s
Forum_access_restricted_content.s
Group_access.s
Light_agent.s
Macro_access.s
Manage_business_rules.s
Manage_contextual_workspaces.s
Manage_dynamic_content.s
Manage_extensions_and_channels.s
Manage_facebook.s
Manage_organization_fields.s
Manage_ticket_fields.s
Manage_ticket_forms.s
Manage_user_fields.s
Moderate_forums.s
Organization_editing.s
Organization_notes_editing.s
Report_access.s
Side_conversation_create.s
Ticket_access.s
Ticket_comment_access.s
Ticket_deletion.s
Ticket_editing.s
Ticket_merge.s
Ticket_tag_editing.s
Twitter_search_access.s
User_view_access.s
View_access.s
View_deleted_tickets.s
Voice_access.s
Voice_dashboard_access.s
created_at.s
description.s
id.s
team_member_count.s
updated_at.s
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"custom_roles")
While i < count_i
CkJsonObject::setCkI(jResp, i)
name = CkJsonObject::ckStringOf(jResp,"custom_roles[i].name")
role_type = CkJsonObject::ckStringOf(jResp,"custom_roles[i].role_type")
Assign_tickets_to_any_group = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.assign_tickets_to_any_group")
Chat_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.chat_access")
End_user_list_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.end_user_list_access")
End_user_profile_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.end_user_profile_access")
Explore_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.explore_access")
Forum_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.forum_access")
Forum_access_restricted_content = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.forum_access_restricted_content")
Group_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.group_access")
Light_agent = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.light_agent")
Macro_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.macro_access")
Manage_business_rules = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_business_rules")
Manage_contextual_workspaces = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_contextual_workspaces")
Manage_dynamic_content = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_dynamic_content")
Manage_extensions_and_channels = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_extensions_and_channels")
Manage_facebook = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_facebook")
Manage_organization_fields = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_organization_fields")
Manage_ticket_fields = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_ticket_fields")
Manage_ticket_forms = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_ticket_forms")
Manage_user_fields = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.manage_user_fields")
Moderate_forums = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.moderate_forums")
Organization_editing = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.organization_editing")
Organization_notes_editing = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.organization_notes_editing")
Report_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.report_access")
Side_conversation_create = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.side_conversation_create")
Ticket_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_access")
Ticket_comment_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_comment_access")
Ticket_deletion = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_deletion")
Ticket_editing = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_editing")
Ticket_merge = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_merge")
Ticket_tag_editing = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.ticket_tag_editing")
Twitter_search_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.twitter_search_access")
User_view_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.user_view_access")
View_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.view_access")
View_deleted_tickets = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.view_deleted_tickets")
Voice_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.voice_access")
Voice_dashboard_access = CkJsonObject::ckStringOf(jResp,"custom_roles[i].configuration.voice_dashboard_access")
created_at = CkJsonObject::ckStringOf(jResp,"custom_roles[i].created_at")
description = CkJsonObject::ckStringOf(jResp,"custom_roles[i].description")
id = CkJsonObject::ckStringOf(jResp,"custom_roles[i].id")
team_member_count = CkJsonObject::ckStringOf(jResp,"custom_roles[i].team_member_count")
updated_at = CkJsonObject::ckStringOf(jResp,"custom_roles[i].updated_at")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
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}"
}
]
}