Chilkat Online Tools

SQL Server / Support API / List Custom Roles

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OASetProperty @http, 'BasicAuth', 1
    EXEC sp_OASetProperty @http, 'Login', 'login'
    EXEC sp_OASetProperty @http, 'Password', 'password'

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://example.zendesk.com/api/v2/custom_roles', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

    -- 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

    DECLARE @name nvarchar(4000)

    DECLARE @role_type nvarchar(4000)

    DECLARE @Assign_tickets_to_any_group nvarchar(4000)

    DECLARE @Chat_access nvarchar(4000)

    DECLARE @End_user_list_access nvarchar(4000)

    DECLARE @End_user_profile_access nvarchar(4000)

    DECLARE @Explore_access nvarchar(4000)

    DECLARE @Forum_access nvarchar(4000)

    DECLARE @Forum_access_restricted_content nvarchar(4000)

    DECLARE @Group_access nvarchar(4000)

    DECLARE @Light_agent nvarchar(4000)

    DECLARE @Macro_access nvarchar(4000)

    DECLARE @Manage_business_rules nvarchar(4000)

    DECLARE @Manage_contextual_workspaces nvarchar(4000)

    DECLARE @Manage_dynamic_content nvarchar(4000)

    DECLARE @Manage_extensions_and_channels nvarchar(4000)

    DECLARE @Manage_facebook nvarchar(4000)

    DECLARE @Manage_organization_fields nvarchar(4000)

    DECLARE @Manage_ticket_fields nvarchar(4000)

    DECLARE @Manage_ticket_forms nvarchar(4000)

    DECLARE @Manage_user_fields nvarchar(4000)

    DECLARE @Moderate_forums nvarchar(4000)

    DECLARE @Organization_editing nvarchar(4000)

    DECLARE @Organization_notes_editing nvarchar(4000)

    DECLARE @Report_access nvarchar(4000)

    DECLARE @Side_conversation_create nvarchar(4000)

    DECLARE @Ticket_access nvarchar(4000)

    DECLARE @Ticket_comment_access nvarchar(4000)

    DECLARE @Ticket_deletion nvarchar(4000)

    DECLARE @Ticket_editing nvarchar(4000)

    DECLARE @Ticket_merge nvarchar(4000)

    DECLARE @Ticket_tag_editing nvarchar(4000)

    DECLARE @Twitter_search_access nvarchar(4000)

    DECLARE @User_view_access nvarchar(4000)

    DECLARE @View_access nvarchar(4000)

    DECLARE @View_deleted_tickets nvarchar(4000)

    DECLARE @Voice_access nvarchar(4000)

    DECLARE @Voice_dashboard_access nvarchar(4000)

    DECLARE @created_at nvarchar(4000)

    DECLARE @description nvarchar(4000)

    DECLARE @id nvarchar(4000)

    DECLARE @team_member_count nvarchar(4000)

    DECLARE @updated_at nvarchar(4000)

    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'custom_roles'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'custom_roles[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @role_type OUT, 'custom_roles[i].role_type'
        EXEC sp_OAMethod @jResp, 'StringOf', @Assign_tickets_to_any_group OUT, 'custom_roles[i].configuration.assign_tickets_to_any_group'
        EXEC sp_OAMethod @jResp, 'StringOf', @Chat_access OUT, 'custom_roles[i].configuration.chat_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @End_user_list_access OUT, 'custom_roles[i].configuration.end_user_list_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @End_user_profile_access OUT, 'custom_roles[i].configuration.end_user_profile_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Explore_access OUT, 'custom_roles[i].configuration.explore_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Forum_access OUT, 'custom_roles[i].configuration.forum_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Forum_access_restricted_content OUT, 'custom_roles[i].configuration.forum_access_restricted_content'
        EXEC sp_OAMethod @jResp, 'StringOf', @Group_access OUT, 'custom_roles[i].configuration.group_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Light_agent OUT, 'custom_roles[i].configuration.light_agent'
        EXEC sp_OAMethod @jResp, 'StringOf', @Macro_access OUT, 'custom_roles[i].configuration.macro_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_business_rules OUT, 'custom_roles[i].configuration.manage_business_rules'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_contextual_workspaces OUT, 'custom_roles[i].configuration.manage_contextual_workspaces'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_dynamic_content OUT, 'custom_roles[i].configuration.manage_dynamic_content'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_extensions_and_channels OUT, 'custom_roles[i].configuration.manage_extensions_and_channels'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_facebook OUT, 'custom_roles[i].configuration.manage_facebook'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_organization_fields OUT, 'custom_roles[i].configuration.manage_organization_fields'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_ticket_fields OUT, 'custom_roles[i].configuration.manage_ticket_fields'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_ticket_forms OUT, 'custom_roles[i].configuration.manage_ticket_forms'
        EXEC sp_OAMethod @jResp, 'StringOf', @Manage_user_fields OUT, 'custom_roles[i].configuration.manage_user_fields'
        EXEC sp_OAMethod @jResp, 'StringOf', @Moderate_forums OUT, 'custom_roles[i].configuration.moderate_forums'
        EXEC sp_OAMethod @jResp, 'StringOf', @Organization_editing OUT, 'custom_roles[i].configuration.organization_editing'
        EXEC sp_OAMethod @jResp, 'StringOf', @Organization_notes_editing OUT, 'custom_roles[i].configuration.organization_notes_editing'
        EXEC sp_OAMethod @jResp, 'StringOf', @Report_access OUT, 'custom_roles[i].configuration.report_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Side_conversation_create OUT, 'custom_roles[i].configuration.side_conversation_create'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_access OUT, 'custom_roles[i].configuration.ticket_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_comment_access OUT, 'custom_roles[i].configuration.ticket_comment_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_deletion OUT, 'custom_roles[i].configuration.ticket_deletion'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_editing OUT, 'custom_roles[i].configuration.ticket_editing'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_merge OUT, 'custom_roles[i].configuration.ticket_merge'
        EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_tag_editing OUT, 'custom_roles[i].configuration.ticket_tag_editing'
        EXEC sp_OAMethod @jResp, 'StringOf', @Twitter_search_access OUT, 'custom_roles[i].configuration.twitter_search_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @User_view_access OUT, 'custom_roles[i].configuration.user_view_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @View_access OUT, 'custom_roles[i].configuration.view_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @View_deleted_tickets OUT, 'custom_roles[i].configuration.view_deleted_tickets'
        EXEC sp_OAMethod @jResp, 'StringOf', @Voice_access OUT, 'custom_roles[i].configuration.voice_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @Voice_dashboard_access OUT, 'custom_roles[i].configuration.voice_dashboard_access'
        EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'custom_roles[i].created_at'
        EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'custom_roles[i].description'
        EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'custom_roles[i].id'
        EXEC sp_OAMethod @jResp, 'StringOf', @team_member_count OUT, 'custom_roles[i].team_member_count'
        EXEC sp_OAMethod @jResp, 'StringOf', @updated_at OUT, 'custom_roles[i].updated_at'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

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}"
    }
  ]
}