Chilkat Online Tools

Android / Support API / Show Custom Role

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    http.put_BasicAuth(true);
    http.put_Login("login");
    http.put_Password("password");

    http.SetRequestHeader("Accept","application/json");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://example.zendesk.com/api/v2/custom_roles/:custom_role_id",sbResponseBody);
    if (success == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = http.get_LastStatus();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, http.lastHeader());
        Log.i(TAG, "Failed.");
        return;
        }

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

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

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

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

Postman Collection Item JSON

{
  "name": "Show Custom Role",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/custom_roles/:custom_role_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "custom_roles",
        ":custom_role_id"
      ],
      "variable": [
        {
          "key": "custom_role_id",
          "value": "<integer>"
        }
      ]
    },
    "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": "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/:custom_role_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "custom_roles",
            ":custom_role_id"
          ],
          "variable": [
            {
              "key": "custom_role_id"
            }
          ]
        }
      },
      "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}"
    }
  ]
}