Chilkat Online Tools

Swift3 / Support API / Update Custom Role

Back to Collection Items

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

    let http = CkoHttp()!
    var success: Bool

    http.basicAuth = true
    http.login = "login"
    http.password = "password"

    http.setRequestHeader("Accept", value: "application/json")

    var resp: CkoHttpResponse? = http.quickRequest("PUT", url: "https://example.zendesk.com/api/v2/custom_roles/:custom_role_id")
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    let sbResponseBody = CkoStringBuilder()!
    resp!.getBodySb(sbResponseBody)

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = resp!.statusCode.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(resp!.header!)")
        print("Failed.")
        resp = nil
        return
    }

    resp = nil

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

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

}

Curl Command

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

Postman Collection Item JSON

{
  "name": "Update Custom Role",
  "request": {
    "method": "PUT",
    "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\nAgents with the `manage_roles` permission\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "PUT",
        "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}"
    }
  ]
}