delphiDll / Support API / Create Custom Role
Back to Collection Items
var
http: HCkHttp;
success: Boolean;
resp: HCkHttpResponse;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
Name: PWideChar;
Role_type: PWideChar;
Assign_tickets_to_any_group: PWideChar;
Chat_access: PWideChar;
End_user_list_access: PWideChar;
End_user_profile_access: PWideChar;
Explore_access: PWideChar;
Forum_access: PWideChar;
Forum_access_restricted_content: PWideChar;
Group_access: PWideChar;
Light_agent: PWideChar;
Macro_access: PWideChar;
Manage_business_rules: PWideChar;
Manage_contextual_workspaces: PWideChar;
Manage_dynamic_content: PWideChar;
Manage_extensions_and_channels: PWideChar;
Manage_facebook: PWideChar;
Manage_organization_fields: PWideChar;
Manage_ticket_fields: PWideChar;
Manage_ticket_forms: PWideChar;
Manage_user_fields: PWideChar;
Moderate_forums: PWideChar;
Organization_editing: PWideChar;
Organization_notes_editing: PWideChar;
Report_access: PWideChar;
Side_conversation_create: PWideChar;
Ticket_access: PWideChar;
Ticket_comment_access: PWideChar;
Ticket_deletion: PWideChar;
Ticket_editing: PWideChar;
Ticket_merge: PWideChar;
Ticket_tag_editing: PWideChar;
Twitter_search_access: PWideChar;
User_view_access: PWideChar;
View_access: PWideChar;
View_deleted_tickets: PWideChar;
Voice_access: PWideChar;
Voice_dashboard_access: PWideChar;
Created_at: PWideChar;
Description: PWideChar;
Id: PWideChar;
Team_member_count: PWideChar;
Updated_at: PWideChar;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
CkHttp_putBasicAuth(http,True);
CkHttp_putLogin(http,'login');
CkHttp_putPassword(http,'password');
CkHttp_SetRequestHeader(http,'Accept','application/json');
resp := CkHttp_QuickRequest(http,'POST','https://example.zendesk.com/api/v2/custom_roles');
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
sbResponseBody := CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttpResponse__header(resp));
Memo1.Lines.Add('Failed.');
CkHttpResponse_Dispose(resp);
Exit;
end;
CkHttpResponse_Dispose(resp);
// 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
Name := CkJsonObject__stringOf(jResp,'custom_role.name');
Role_type := CkJsonObject__stringOf(jResp,'custom_role.role_type');
Assign_tickets_to_any_group := CkJsonObject__stringOf(jResp,'custom_role.configuration.assign_tickets_to_any_group');
Chat_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.chat_access');
End_user_list_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.end_user_list_access');
End_user_profile_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.end_user_profile_access');
Explore_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.explore_access');
Forum_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.forum_access');
Forum_access_restricted_content := CkJsonObject__stringOf(jResp,'custom_role.configuration.forum_access_restricted_content');
Group_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.group_access');
Light_agent := CkJsonObject__stringOf(jResp,'custom_role.configuration.light_agent');
Macro_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.macro_access');
Manage_business_rules := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_business_rules');
Manage_contextual_workspaces := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_contextual_workspaces');
Manage_dynamic_content := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_dynamic_content');
Manage_extensions_and_channels := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_extensions_and_channels');
Manage_facebook := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_facebook');
Manage_organization_fields := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_organization_fields');
Manage_ticket_fields := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_ticket_fields');
Manage_ticket_forms := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_ticket_forms');
Manage_user_fields := CkJsonObject__stringOf(jResp,'custom_role.configuration.manage_user_fields');
Moderate_forums := CkJsonObject__stringOf(jResp,'custom_role.configuration.moderate_forums');
Organization_editing := CkJsonObject__stringOf(jResp,'custom_role.configuration.organization_editing');
Organization_notes_editing := CkJsonObject__stringOf(jResp,'custom_role.configuration.organization_notes_editing');
Report_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.report_access');
Side_conversation_create := CkJsonObject__stringOf(jResp,'custom_role.configuration.side_conversation_create');
Ticket_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_access');
Ticket_comment_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_comment_access');
Ticket_deletion := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_deletion');
Ticket_editing := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_editing');
Ticket_merge := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_merge');
Ticket_tag_editing := CkJsonObject__stringOf(jResp,'custom_role.configuration.ticket_tag_editing');
Twitter_search_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.twitter_search_access');
User_view_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.user_view_access');
View_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.view_access');
View_deleted_tickets := CkJsonObject__stringOf(jResp,'custom_role.configuration.view_deleted_tickets');
Voice_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.voice_access');
Voice_dashboard_access := CkJsonObject__stringOf(jResp,'custom_role.configuration.voice_dashboard_access');
Created_at := CkJsonObject__stringOf(jResp,'custom_role.created_at');
Description := CkJsonObject__stringOf(jResp,'custom_role.description');
Id := CkJsonObject__stringOf(jResp,'custom_role.id');
Team_member_count := CkJsonObject__stringOf(jResp,'custom_role.team_member_count');
Updated_at := CkJsonObject__stringOf(jResp,'custom_role.updated_at');
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
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}"
}
]
}