SQL Server / Zoom API / List SIP phones
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
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_number', 1
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'search_key', 'quis officia in reprehenderit'
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_size', 68423085
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'next_page_token', 'quis officia in reprehenderit'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.zoom.us/v2/sip_phones', @queryParams
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 @queryParams
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.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 @queryParams
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)
-- {
-- "page_count": 1,
-- "page_number": 1,
-- "page_size": 1,
-- "total_records": 1,
-- "phones": [
-- {
-- "id": "123456",
-- "user_email": "example@example.com",
-- "domain": "example.com",
-- "register_server": "192.0.2.1",
-- "transport_protocol": "UDP",
-- "proxy_server": "192.0.2.2",
-- "register_server2": "192.0.2.3",
-- "transport_protocol2": "UDP",
-- "proxy_server2": "192.0.2.4",
-- "register_server3": "192.0.2.5",
-- "transport_protocol3": "UDP",
-- "proxy_server3": "192.0.2.6",
-- "registration_expire_time": 60,
-- "user_name": "1008",
-- "password": "apassword1",
-- "authorization_name": "testname",
-- "voice_mail": "4000"
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @id nvarchar(4000)
DECLARE @user_email nvarchar(4000)
DECLARE @domain nvarchar(4000)
DECLARE @register_server nvarchar(4000)
DECLARE @transport_protocol nvarchar(4000)
DECLARE @proxy_server nvarchar(4000)
DECLARE @register_server2 nvarchar(4000)
DECLARE @transport_protocol2 nvarchar(4000)
DECLARE @proxy_server2 nvarchar(4000)
DECLARE @register_server3 nvarchar(4000)
DECLARE @transport_protocol3 nvarchar(4000)
DECLARE @proxy_server3 nvarchar(4000)
DECLARE @registration_expire_time int
DECLARE @user_name nvarchar(4000)
DECLARE @password nvarchar(4000)
DECLARE @authorization_name nvarchar(4000)
DECLARE @voice_mail nvarchar(4000)
DECLARE @page_count int
EXEC sp_OAMethod @jResp, 'IntOf', @page_count OUT, 'page_count'
DECLARE @page_number int
EXEC sp_OAMethod @jResp, 'IntOf', @page_number OUT, 'page_number'
DECLARE @page_size int
EXEC sp_OAMethod @jResp, 'IntOf', @page_size OUT, 'page_size'
DECLARE @total_records int
EXEC sp_OAMethod @jResp, 'IntOf', @total_records OUT, 'total_records'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'phones'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'phones[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @user_email OUT, 'phones[i].user_email'
EXEC sp_OAMethod @jResp, 'StringOf', @domain OUT, 'phones[i].domain'
EXEC sp_OAMethod @jResp, 'StringOf', @register_server OUT, 'phones[i].register_server'
EXEC sp_OAMethod @jResp, 'StringOf', @transport_protocol OUT, 'phones[i].transport_protocol'
EXEC sp_OAMethod @jResp, 'StringOf', @proxy_server OUT, 'phones[i].proxy_server'
EXEC sp_OAMethod @jResp, 'StringOf', @register_server2 OUT, 'phones[i].register_server2'
EXEC sp_OAMethod @jResp, 'StringOf', @transport_protocol2 OUT, 'phones[i].transport_protocol2'
EXEC sp_OAMethod @jResp, 'StringOf', @proxy_server2 OUT, 'phones[i].proxy_server2'
EXEC sp_OAMethod @jResp, 'StringOf', @register_server3 OUT, 'phones[i].register_server3'
EXEC sp_OAMethod @jResp, 'StringOf', @transport_protocol3 OUT, 'phones[i].transport_protocol3'
EXEC sp_OAMethod @jResp, 'StringOf', @proxy_server3 OUT, 'phones[i].proxy_server3'
EXEC sp_OAMethod @jResp, 'IntOf', @registration_expire_time OUT, 'phones[i].registration_expire_time'
EXEC sp_OAMethod @jResp, 'StringOf', @user_name OUT, 'phones[i].user_name'
EXEC sp_OAMethod @jResp, 'StringOf', @password OUT, 'phones[i].password'
EXEC sp_OAMethod @jResp, 'StringOf', @authorization_name OUT, 'phones[i].authorization_name'
EXEC sp_OAMethod @jResp, 'StringOf', @voice_mail OUT, 'phones[i].voice_mail'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "page_number=1"
-d "search_key=quis%20officia%20in%20reprehenderit"
-d "page_size=68423085"
-d "next_page_token=quis%20officia%20in%20reprehenderit"
-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/sip_phones
Postman Collection Item JSON
{
"name": "List SIP phones",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/sip_phones?page_number=1&search_key=quis officia in reprehenderit&page_size=68423085&next_page_token=quis officia in reprehenderit",
"host": [
"{{baseUrl}}"
],
"path": [
"sip_phones"
],
"query": [
{
"key": "page_number",
"value": "1",
"description": "**Deprecated.** We will no longer support this field in a future release. Instead, use the `next_page_token` for pagination."
},
{
"key": "search_key",
"value": "quis officia in reprehenderit",
"description": "User name or email address of a user. If this parameter is provided, only the SIP phone system integration enabled for that specific user will be returned. Otherwise, all SIP phones on an account will be returned."
},
{
"key": "page_size",
"value": "68423085",
"description": "The number of records returned within a single API call."
},
{
"key": "next_page_token",
"value": "quis officia in reprehenderit",
"description": "The next page token is used to paginate through large result sets. A next page token will be returned whenever the set of available results exceeds the current page size. The expiration period for this token is 15 minutes."
}
]
},
"description": "Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to list SIP phones on an account.<br><br>\n**Prerequisites**:\n* Currently only supported on Cisco and Avaya PBX systems. \n* User must enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:read:admin`<br> \n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`<br>\n"
},
"response": [
{
"name": "**HTTP Status Code:** `200`<br>\nSIP Phones listed successfully.\n\n**Error Code:** `200`<br>\nPermission missing: Enable SIP Phone Integration by contacting a Zoom Admin first.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/sip_phones?page_number=1&search_key=quis officia in reprehenderit&page_size=68423085&next_page_token=quis officia in reprehenderit",
"host": [
"{{baseUrl}}"
],
"path": [
"sip_phones"
],
"query": [
{
"key": "page_number",
"value": "1"
},
{
"key": "search_key",
"value": "quis officia in reprehenderit"
},
{
"key": "page_size",
"value": "68423085"
},
{
"key": "next_page_token",
"value": "quis officia in reprehenderit"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"page_count\": 1,\n \"page_number\": 1,\n \"page_size\": 1,\n \"total_records\": 1,\n \"phones\": [\n {\n \"id\": \"123456\",\n \"user_email\": \"example@example.com\",\n \"domain\": \"example.com\",\n \"register_server\": \"192.0.2.1\",\n \"transport_protocol\": \"UDP\",\n \"proxy_server\": \"192.0.2.2\",\n \"register_server2\": \"192.0.2.3\",\n \"transport_protocol2\": \"UDP\",\n \"proxy_server2\": \"192.0.2.4\",\n \"register_server3\": \"192.0.2.5\",\n \"transport_protocol3\": \"UDP\",\n \"proxy_server3\": \"192.0.2.6\",\n \"registration_expire_time\": 60,\n \"user_name\": \"1008\",\n \"password\": \"apassword1\",\n \"authorization_name\": \"testname\",\n \"voice_mail\": \"4000\"\n }\n ]\n}"
},
{
"name": "**HTTP Status Code:** `400`<br> Bad Request\n\n",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/sip_phones?page_number=1&search_key=quis officia in reprehenderit&page_size=68423085&next_page_token=quis officia in reprehenderit",
"host": [
"{{baseUrl}}"
],
"path": [
"sip_phones"
],
"query": [
{
"key": "page_number",
"value": "1"
},
{
"key": "search_key",
"value": "quis officia in reprehenderit"
},
{
"key": "page_size",
"value": "68423085"
},
{
"key": "next_page_token",
"value": "quis officia in reprehenderit"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}