Chilkat Online Tools

Swift3 / Zoom API / Get a channel

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

    // Adds the "Authorization: Bearer <access_token>" header.
    http.authToken = "<access_token>"

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://api.zoom.us/v2/chat/channels/:channelId", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

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

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

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("Failed.")
        return
    }

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

    // {
    //   "id": "cabc1234567defghijkl01234",
    //   "jid": "cabc1234567defghijkl01234@conference.xmpp.zoom.us",
    //   "name": "common2",
    //   "type": 5,
    //   "channel_settings": {
    //     "new_members_can_see_previous_messages_files": true,
    //     "allow_to_add_external_users": 1,
    //     "posting_permissions": 1
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    var id: String? = jResp.string(of: "id")
    var jid: String? = jResp.string(of: "jid")
    var name: String? = jResp.string(of: "name")
    var v_type: Int = jResp.int(of: "type").intValue
    var New_members_can_see_previous_messages_files: Bool = jResp.bool(of: "channel_settings.new_members_can_see_previous_messages_files")
    var Allow_to_add_external_users: Int = jResp.int(of: "channel_settings.allow_to_add_external_users").intValue
    var Posting_permissions: Int = jResp.int(of: "channel_settings.posting_permissions").intValue

}

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/chat/channels/:channelId

Postman Collection Item JSON

{
  "name": "Get a channel",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/chat/channels/:channelId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "chat",
        "channels",
        ":channelId"
      ],
      "variable": [
        {
          "key": "channelId",
          "value": "quis officia in reprehenderit",
          "description": "(Required) Channel ID: Unique Identifier of a channel."
        }
      ]
    },
    "description": "Zoom chat [channels](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) allow users to communicate via chat in private or public groups. Use this API to get information about a specific channel. \n\n**Scope:** `chat_channel:read`\t<br>\n**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`\n\n<p style=\"background-color:#e1f5fe; color:#000000; padding:8px\"> <b>Note: </b> This API supports only <b>user-managed</b> <a href=\"https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app\">OAuth apps</a>. If you use an Account-Level OAuth Access token, you can only retrieve the channel information for the authorized user. You can't retrieve the channel information of other account users. Use the <a href=\"https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-channels-account-level/getchannel\">Account-Level Get Channel Info API</a> to retrieve the channel information of other account users.</p><br>\n\n\n "
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nChannel returned.<br>\n\n\n\n",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/chat/channels/:channelId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "channels",
            ":channelId"
          ],
          "variable": [
            {
              "key": "channelId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Channel ID: Unique Identifier of a channel."
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"cabc1234567defghijkl01234\",\n \"jid\": \"cabc1234567defghijkl01234@conference.xmpp.zoom.us\",\n \"name\": \"common2\",\n \"type\": 5,\n \"channel_settings\": {\n  \"new_members_can_see_previous_messages_files\": true,\n  \"allow_to_add_external_users\": 1,\n  \"posting_permissions\": 1\n }\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\nBad Request<br>\n**Error Code:** `200`<br>\nUnauthorized request. You do not have permission to access this user's channel information.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/chat/channels/:channelId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "channels",
            ":channelId"
          ],
          "variable": [
            {
              "key": "channelId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Channel ID: Unique Identifier of a channel."
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "**Status Code:** `404`<br>\nNot found.<br>\n**Error Code:** `4130`<br>\nChannel does not exist: $channelId.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/chat/channels/:channelId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "channels",
            ":channelId"
          ],
          "variable": [
            {
              "key": "channelId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Channel ID: Unique Identifier of a channel."
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}