Chilkat Online Tools

SQL Server / Zoom API / Subscribe account to an additional plan

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @req int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.HttpRequest', @req OUT

    EXEC sp_OASetProperty @req, 'HttpVerb', 'POST'
    EXEC sp_OASetProperty @req, 'Path', '/v2/accounts/:accountId/plans/addons'
    EXEC sp_OASetProperty @req, 'ContentType', 'multipart/form-data'
    EXEC sp_OAMethod @req, 'AddParam', NULL, '', ''

    EXEC sp_OAMethod @req, 'AddParam', NULL, 'hosts', 'exercitation con42949372'

    EXEC sp_OAMethod @req, 'AddHeader', NULL, 'Authorization', 'Bearer <access_token>'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, 'api.zoom.us', 443, 1, @req
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @req
        RETURN
      END

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @req
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END
    EXEC @hr = sp_OADestroy @resp

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

    -- {
    --   "plan_base": {
    --     "type": "monthly",
    --     "hosts": 100,
    --     "partner_sku": "PAR3-PRO-BASE-MTH",
    --     "discount_rate": 13.53,
    --     "discount_percent": 0
    --   }
    -- }

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

    DECLARE @v_Type nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'plan_base.type'
    DECLARE @Hosts int
    EXEC sp_OAMethod @jResp, 'IntOf', @Hosts OUT, 'plan_base.hosts'
    DECLARE @Partner_sku nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Partner_sku OUT, 'plan_base.partner_sku'
    DECLARE @Discount_rate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Discount_rate OUT, 'plan_base.discount_rate'
    DECLARE @Discount_percent int
    EXEC sp_OAMethod @jResp, 'IntOf', @Discount_percent OUT, 'plan_base.discount_percent'

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @req
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'type=exercitation con'
	--form 'hosts=exercitation con42949372'
https://api.zoom.us/v2/accounts/:accountId/plans/addons

Postman Collection Item JSON

{
  "name": "Subscribe account to an additional plan",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "type",
          "value": "exercitation con",
          "description": "undefined",
          "type": "text"
        },
        {
          "key": "hosts",
          "value": "42949372",
          "description": "undefined",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/accounts/:accountId/plans/addons",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "accounts",
        ":accountId",
        "plans",
        "addons"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "quis officia in reprehenderit",
          "description": "(Required) The account's ID."
        }
      ]
    },
    "description": "Use this API to subscribe a subaccount to a Zoom addon plan. \n\n This API can only be used by Master accounts that pay all billing charges of their associated Pro or higher subaccounts. Zoom only allows approved partners to use [Master APIs](https://marketplace.zoom.us/docs/api-reference/master-account-apis) and manage subaccounts' billing information. Email the partner programs team at [**partner-success@zoom.us**](mailto:partner-success@zoom.us) for more details. \n\n **Scopes**: `billing:master` <br> **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy` \n\n **Prerequisites:** \n* A Pro or a higher plan with the **Master account** option enabled. \n* The subaccount **must** be a paid account whose billing charges are paid by its Master account."
  },
  "response": [
    {
      "name": "Information about the account's updated additional plans.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "type",
              "value": "exercitation con",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "hosts",
              "value": "42949372",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/addons",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "addons"
          ],
          "variable": [
            {
              "key": "accountId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) The account's ID."
            }
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"plan_base\": {\n  \"type\": \"monthly\",\n  \"hosts\": 100,\n  \"partner_sku\": \"PAR3-PRO-BASE-MTH\",\n  \"discount_rate\": 13.53,\n  \"discount_percent\": 0\n }\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\n**Error Code:** `2100`<br> \nThis sub account is on self pay mode.<br>\nCannot update Additional plan for a sub account under free plan.<br>\nAdditional Zoom Rooms plan cannot be added to a sub account that already has a Zoom ",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "type",
              "value": "exercitation con",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "hosts",
              "value": "42949372",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/addons",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "addons"
          ],
          "variable": [
            {
              "key": "accountId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) The account's ID."
            }
          ]
        }
      },
      "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.<br>\n**Error Code:** `2001`<br> \nAccount does not exist: {subAccountId}.\n",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "type",
              "value": "exercitation con",
              "description": "undefined",
              "type": "text"
            },
            {
              "key": "hosts",
              "value": "42949372",
              "description": "undefined",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/addons",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "addons"
          ],
          "variable": [
            {
              "key": "accountId",
              "value": "quis officia in reprehenderit",
              "description": "(Required) The account's ID."
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}