Chilkat Online Tools

Xojo / Support API / Create Custom Role

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

http.BasicAuth = True
http.Login = "login"
http.Password = "password"

http.SetRequestHeader "Accept","application/json"

Dim resp As Chilkat.HttpResponse
resp = http.QuickRequest("POST","https://example.zendesk.com/api/v2/custom_roles")
If (http.LastMethodSuccess = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")

    Return
End If

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

// {
//   "custom_role": {
//     "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

Dim Name As String
Name = jResp.StringOf("custom_role.name")
Dim Role_type As String
Role_type = jResp.StringOf("custom_role.role_type")
Dim Assign_tickets_to_any_group As String
Assign_tickets_to_any_group = jResp.StringOf("custom_role.configuration.assign_tickets_to_any_group")
Dim Chat_access As String
Chat_access = jResp.StringOf("custom_role.configuration.chat_access")
Dim End_user_list_access As String
End_user_list_access = jResp.StringOf("custom_role.configuration.end_user_list_access")
Dim End_user_profile_access As String
End_user_profile_access = jResp.StringOf("custom_role.configuration.end_user_profile_access")
Dim Explore_access As String
Explore_access = jResp.StringOf("custom_role.configuration.explore_access")
Dim Forum_access As String
Forum_access = jResp.StringOf("custom_role.configuration.forum_access")
Dim Forum_access_restricted_content As String
Forum_access_restricted_content = jResp.StringOf("custom_role.configuration.forum_access_restricted_content")
Dim Group_access As String
Group_access = jResp.StringOf("custom_role.configuration.group_access")
Dim Light_agent As String
Light_agent = jResp.StringOf("custom_role.configuration.light_agent")
Dim Macro_access As String
Macro_access = jResp.StringOf("custom_role.configuration.macro_access")
Dim Manage_business_rules As String
Manage_business_rules = jResp.StringOf("custom_role.configuration.manage_business_rules")
Dim Manage_contextual_workspaces As String
Manage_contextual_workspaces = jResp.StringOf("custom_role.configuration.manage_contextual_workspaces")
Dim Manage_dynamic_content As String
Manage_dynamic_content = jResp.StringOf("custom_role.configuration.manage_dynamic_content")
Dim Manage_extensions_and_channels As String
Manage_extensions_and_channels = jResp.StringOf("custom_role.configuration.manage_extensions_and_channels")
Dim Manage_facebook As String
Manage_facebook = jResp.StringOf("custom_role.configuration.manage_facebook")
Dim Manage_organization_fields As String
Manage_organization_fields = jResp.StringOf("custom_role.configuration.manage_organization_fields")
Dim Manage_ticket_fields As String
Manage_ticket_fields = jResp.StringOf("custom_role.configuration.manage_ticket_fields")
Dim Manage_ticket_forms As String
Manage_ticket_forms = jResp.StringOf("custom_role.configuration.manage_ticket_forms")
Dim Manage_user_fields As String
Manage_user_fields = jResp.StringOf("custom_role.configuration.manage_user_fields")
Dim Moderate_forums As String
Moderate_forums = jResp.StringOf("custom_role.configuration.moderate_forums")
Dim Organization_editing As String
Organization_editing = jResp.StringOf("custom_role.configuration.organization_editing")
Dim Organization_notes_editing As String
Organization_notes_editing = jResp.StringOf("custom_role.configuration.organization_notes_editing")
Dim Report_access As String
Report_access = jResp.StringOf("custom_role.configuration.report_access")
Dim Side_conversation_create As String
Side_conversation_create = jResp.StringOf("custom_role.configuration.side_conversation_create")
Dim Ticket_access As String
Ticket_access = jResp.StringOf("custom_role.configuration.ticket_access")
Dim Ticket_comment_access As String
Ticket_comment_access = jResp.StringOf("custom_role.configuration.ticket_comment_access")
Dim Ticket_deletion As String
Ticket_deletion = jResp.StringOf("custom_role.configuration.ticket_deletion")
Dim Ticket_editing As String
Ticket_editing = jResp.StringOf("custom_role.configuration.ticket_editing")
Dim Ticket_merge As String
Ticket_merge = jResp.StringOf("custom_role.configuration.ticket_merge")
Dim Ticket_tag_editing As String
Ticket_tag_editing = jResp.StringOf("custom_role.configuration.ticket_tag_editing")
Dim Twitter_search_access As String
Twitter_search_access = jResp.StringOf("custom_role.configuration.twitter_search_access")
Dim User_view_access As String
User_view_access = jResp.StringOf("custom_role.configuration.user_view_access")
Dim View_access As String
View_access = jResp.StringOf("custom_role.configuration.view_access")
Dim View_deleted_tickets As String
View_deleted_tickets = jResp.StringOf("custom_role.configuration.view_deleted_tickets")
Dim Voice_access As String
Voice_access = jResp.StringOf("custom_role.configuration.voice_access")
Dim Voice_dashboard_access As String
Voice_dashboard_access = jResp.StringOf("custom_role.configuration.voice_dashboard_access")
Dim Created_at As String
Created_at = jResp.StringOf("custom_role.created_at")
Dim Description As String
Description = jResp.StringOf("custom_role.description")
Dim Id As String
Id = jResp.StringOf("custom_role.id")
Dim Team_member_count As String
Team_member_count = jResp.StringOf("custom_role.team_member_count")
Dim Updated_at As String
Updated_at = jResp.StringOf("custom_role.updated_at")

Curl Command

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

Postman Collection Item JSON

{
  "name": "Create Custom Role",
  "request": {
    "method": "POST",
    "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* Administrators\n* Agents with the `manage_roles` permission\n"
  },
  "response": [
    {
      "name": "Created response",
      "originalRequest": {
        "method": "POST",
        "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_role\": {\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}"
    }
  ]
}