Chilkat Online Tools

DataFlex / Zoom API / Create a channel

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sName
    Integer iV_type
    String sJid
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComPath Of hoReq To "/v2/chat/users/:userId/channels"
    Set ComContentType Of hoReq To "multipart/form-data"
    Send ComAddParam To hoReq "commodo pariatur" ""

    Send ComAddParam To hoReq "" ""

    Send ComAddParam To hoReq "members" 'commodo pariatur2[{"email":"JYf2Jw@cwWEvssuRBRvdy.qba"},{"email":"qDmT-y@zKQCxRvyuVeHgBe.iyjb"}]'

    Send ComAddHeader To hoReq "Authorization" "Bearer <access_token>"

    Get pvComObject of hoReq to vReq
    Get ComSynchronousRequest Of hoHttp "api.zoom.us" 443 True vReq To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    // {
    //   "id": "id8977ullamco",
    //   "name": "Happy Channel",
    //   "type": 1,
    //   "jid": "nisi73624365536st"
    // }

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

    Get ComStringOf Of hoJResp "id" To sId
    Get ComStringOf Of hoJResp "name" To sName
    Get ComIntOf Of hoJResp "type" To iV_type
    Get ComStringOf Of hoJResp "jid" To sJid


End_Procedure

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'name=commodo pariatur'
	--form 'type=commodo pariatur2'
	--form 'members=commodo pariatur2[{"email":"JYf2Jw@cwWEvssuRBRvdy.qba"},{"email":"qDmT-y@zKQCxRvyuVeHgBe.iyjb"}]'
https://api.zoom.us/v2/chat/users/:userId/channels

Postman Collection Item JSON

{
  "name": "Create a channel",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "name",
          "value": "commodo pariatur",
          "description": "Name of the channel.",
          "type": "text"
        },
        {
          "key": "type",
          "value": "2",
          "description": "Type of the channel. The value can be one of the following:<br>\n`1`: Private channel. In this type of channel, members must be invited to join a channel.<br>\n`2`: Private channel with members that belong to one Zoom account. Members in this channel should be invited and the members should be from the same organization.<br>\n`3`: Public channel. Anyone can search for this channel and join the channel.<br>\n`4`: New chat. This is an instant channel which can be created by adding members to a new chat.  (This can only be one of 1,2,3)",
          "type": "text"
        },
        {
          "key": "members",
          "value": "[{\"email\":\"JYf2Jw@cwWEvssuRBRvdy.qba\"},{\"email\":\"qDmT-y@zKQCxRvyuVeHgBe.iyjb\"}]",
          "description": "Member(s) to include in the channel. A max of 5 members can be added to the channel at once with this API.",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/chat/users/:userId/channels",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "chat",
        "users",
        ":userId",
        "channels"
      ],
      "variable": [
        {
          "key": "userId",
          "value": "quis officia in reprehenderit",
          "description": "(Required) Unique identifier of the user."
        }
      ]
    },
    "description": "Use this API to create a channel for a user. For user-level apps, pass [the `me` value](https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#mekeyword) instead of the `userId` parameter.\n\nZoom chat channels allow users to communicate via chat in private or public groups.\n\n**Scopes:** `chat_channel:write` or `chat_channel:write:admin`<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`\n\n<p style=\"background-color:#e1f5fe; color:#01579b; padding:8px\"> <b>Note:</b> This API supports both user-managed apps and account-level apps. However, in an <b>account-level</b> <a href=\"https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app\">OAuth app</a>, to create a channel on behalf of another user in the same Zoom account, the user calling this API must have a <a href=\"https://support.zoom.us/hc/en-us/articles/115001078646-Using-role-management#:~:text=Each%20user%20in%20a%20Zoom,owner%2C%20administrator%2C%20or%20member.&text=Role%2Dbased%20access%20control%20enables,needs%20to%20view%20or%20edit.\">role</a> that has the <b>Edit</b> permission for the <b>Chat channels</b> feature.</p>"
  },
  "response": [
    {
      "name": "**Status Code**: `201` <br>\nChannel created.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "name",
              "value": "occaecat in aliquip nulla",
              "description": "Name of the channel.",
              "type": "text"
            },
            {
              "key": "type",
              "value": "3",
              "description": "Type of the channel. The value can be one of the following:<br>\n`1`: Private channel. In this type of channel, members must be invited to join a channel.<br>\n`2`: Private channel with members that belong to one Zoom account. Members in this channel should be invited and the members should be from the same organization.<br>\n`3`: Public channel. Anyone can search for this channel and join the channel.<br>\n`4`: New chat. This is an instant channel which can be created by adding members to a new chat.  (This can only be one of 1,2,3)",
              "type": "text"
            },
            {
              "key": "members",
              "value": "[{\"email\":\"gtSSd5@lffjSGxDBEFSxCtWv.xnr\"},{\"email\":\"qz4@reFKpgzaYYBkbBzLtCAnRH.pwrf\"}]",
              "description": "Member(s) to include in the channel. A max of 5 members can be added to the channel at once with this API.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/chat/users/:userId/channels",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "users",
            ":userId",
            "channels"
          ],
          "variable": [
            {
              "key": "userId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Unique identifier of the user."
            }
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"id8977ullamco\",\n \"name\": \"Happy Channel\",\n \"type\": 1,\n \"jid\": \"nisi73624365536st\"\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\nNot found.<br>\n**Error Code**: `5301`<br>\nRequest to create a channel failed.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "name",
              "value": "occaecat in aliquip nulla",
              "description": "Name of the channel.",
              "type": "text"
            },
            {
              "key": "type",
              "value": "3",
              "description": "Type of the channel. The value can be one of the following:<br>\n`1`: Private channel. In this type of channel, members must be invited to join a channel.<br>\n`2`: Private channel with members that belong to one Zoom account. Members in this channel should be invited and the members should be from the same organization.<br>\n`3`: Public channel. Anyone can search for this channel and join the channel.<br>\n`4`: New chat. This is an instant channel which can be created by adding members to a new chat.  (This can only be one of 1,2,3)",
              "type": "text"
            },
            {
              "key": "members",
              "value": "[{\"email\":\"gtSSd5@lffjSGxDBEFSxCtWv.xnr\"},{\"email\":\"qz4@reFKpgzaYYBkbBzLtCAnRH.pwrf\"}]",
              "description": "Member(s) to include in the channel. A max of 5 members can be added to the channel at once with this API.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/chat/users/:userId/channels",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "users",
            ":userId",
            "channels"
          ],
          "variable": [
            {
              "key": "userId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Unique identifier of the user."
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "**HTTP Status Code:** `404`<br>\n**Error Code**: `1001`<br>\nUser does not exist: $userId.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "name",
              "value": "occaecat in aliquip nulla",
              "description": "Name of the channel.",
              "type": "text"
            },
            {
              "key": "type",
              "value": "3",
              "description": "Type of the channel. The value can be one of the following:<br>\n`1`: Private channel. In this type of channel, members must be invited to join a channel.<br>\n`2`: Private channel with members that belong to one Zoom account. Members in this channel should be invited and the members should be from the same organization.<br>\n`3`: Public channel. Anyone can search for this channel and join the channel.<br>\n`4`: New chat. This is an instant channel which can be created by adding members to a new chat.  (This can only be one of 1,2,3)",
              "type": "text"
            },
            {
              "key": "members",
              "value": "[{\"email\":\"gtSSd5@lffjSGxDBEFSxCtWv.xnr\"},{\"email\":\"qz4@reFKpgzaYYBkbBzLtCAnRH.pwrf\"}]",
              "description": "Member(s) to include in the channel. A max of 5 members can be added to the channel at once with this API.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/chat/users/:userId/channels",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "chat",
            "users",
            ":userId",
            "channels"
          ],
          "variable": [
            {
              "key": "userId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) Unique identifier of the user."
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}