Hello all,
a quick introduction to the Poly G7500 Command-Line API Reference Guide or the Poly G7500 Command-Line API Reference Guide
Please always ensure you are using the latest >Poly VideoOS REST API< and/or >Poly Command-Line API< from the User and Administrator Documents >here<
If a UI is preferred a Tool like https://www.postman.com/ can be used. Instructions similar to this are >here<
Command-Line API
Enabling the Command Line access via Security > Access will either prompt you for the standard user name of the unit (factory default admin) using ssh and/or the password.
Using for example:
addrbook all
will return all the Speed Dials added to the system.
REST API
Based on the above REST API documentation in order to establish a session a user would initially login to the system:
curl -b cookies.txt -c cookies.txt -d "{\"user\": \"admin\",\"password\": \"123\"}" -H "Content-Type: application/json" -k https://192.168.0.9/rest/session
For the above, we use CURL as this can be used with Windows 10 MS-Dos and/or Linux machines.
The reply includes the sessionId which we store in the cookie.txt
{"loginStatus":{"failedLogins":0,"isPasswordAgeLimitReached":false,"lastLoginClient":"127.0.0.1","lastLoginClientType":"WEB","lastLoginTime":1591786577000,"loginResult":"NOLOCKOUT"},"session":{"clientType":"WEB","creationTime":2688,"isAuthenticated":true,"isConnected":false,"isNew":true,"isStale":false,"location":"192.168.0.5","role":"ADMIN","sessionId":"PSVG+zUra9TcTFaKpvG0RUP6J6ITchMilk70Gc3k4Rydr0N6Uy","userId":"admin"},"success":true}
We can then continue to use this cookie.txt
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_192.168.0.9 FALSE / TRUE 0 session_id PSVG+zUra9TcTFaKpvG0RUP6J6ITchMilk70Gc3k4Rydr0N6Uy
to continue the session
curl -b cookies.txt -c cookies.txt -k https://192.168.0.9/rest/system
and the G7500 and/or Studio X will respond
{"build":"216109","buildType":"dev","hardwareVersion":"1","lanStatus":{"duplex":"FULL","speedMbps":1000,"state":"LAN_UP"},"model":"StudioX50","rebootNeeded":false,"serialNumber":"8L19445XXXXXX","softwareVersion":"3.1.1","state":"READY","systemName":"BaierSteffenGSeries","systemTime":1591789081000,"timeOffset":10800000,"timeServerState":"TIMESERVER_UP","uptime":2689.95}
Reboot a single Studio X or G7500 alone:
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"123\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -H "Content-Type: application/JSON" -k https://10.252.149.104/rest/system/reboot -d "{\"action\": \"reboot\"}"
Reboot a single Studio X or G7500 and all peripherals:
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"789\"}" -H "Content-Type: application/json" -k https://172.19.141.52/rest/session
curl -b cookies.txt -c cookies.txt -H "Content-Type: application/JSON" -k https://172.19.141.52/rest/system/reboot -d "{\"action\": \"reboot\" , \"restartAll\": \"True\"}"
Disable the Wireless advertisement of MiraCast and/or Airplay:
1st we check the current setting
curl -b cookies.txt -c cookies.txt -d "{\"user\": \"admin\",\"password\": \"626DFB\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"system.network.wireless.wifi.enabled\"]}"
The system will respond with
{"vars":[{"name":"system.network.wireless.wifi.enabled","result":"NOERROR","value":"True","isEditable":true,"isHidden":false,"isSecure":false}]}
In the above case the Wireless in Security - Wireless Security is enabled.
We can then also check the Miracast
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"cast.miracast.enabled\"]}"
{"vars":[{"name":"cast.miracast.enabled","result":"NOERROR","value":"True","isEditable":false,"isHidden":false,"isSecure":false}]}
and/or Airplay state
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"cast.airplay.enabled\"]}"
{"vars":[{"name":"cast.airplay.enabled","result":"NOERROR","value":"True","isEditable":true,"isHidden":false,"isSecure":false}]}
or Bluetooth
curl -b cookies.txt -c cookies.txt -d "{\"user\": \"admin\",\"password\": \"626DFB\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"system.network.wireless.bt.enabled\"]}"
{"vars":[{"name":"system.network.wireless.bt.enabled","result":"NOERROR","value":"True","isEditable":true,"isHidden":false,"isSecure":false}]}
In order to disable all broadcasting WiFi and Bluetooth for example in Partner Modes simply set all to False:
curl -b cookies.txt -c cookies.txt -d "{\"user\": \"admin\",\"password\": \"626DFB\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"system.network.wireless.wifi.enabled\"]}"
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"names\": [\"system.network.wireless.bt.enabled\"]}"
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"vars\":[{\"name\":\"cast.airplay.enabled\",\"value\":\"False\"}]}
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"vars\":[{\"name\":\"cast.miracast.enabled\",\"value\":\"False\"}]}
curl -b cookies.txt -c cookies.txt -X POST -H "Content-Type: application/json" -k https://10.252.149.104/rest/config -d "{\"vars\":[{\"name\":\"system.network.wireless.bt.enabled\",\"value\":\"False\"}]}
Disable the Device Mode
Check if the Device mode is active:
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"123\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X GET -H "Content-Type: application/json" -k https://10.252.149.104/rest/system/mode/device
The system responds with:
{"result":true}
Disabling the device mode:
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"123\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X DELETE -H "Content-Type: application/json" -k https://10.252.149.104/rest/system/mode/device
The system responds with
{"success":true}
Use POST instead of DELETE to set the Device mode
Remote Control Check
Check the battery status of a Bluetooth remote:
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\",\"password\": \"789\"}" -H "Content-Type: application/json" -k https://10.252.149.104/rest/session
curl -b cookies.txt -c cookies.txt -X GET -H "Content-Type: application/JSON" -k https://10.252.149.104/rest/system/bluetooth
Please be aware this is working at present but could change at any point. If you need this ensured please work with Poly sales to request this to be documented.
The reply would be (if a remote is paired):
[{"batteryLevel":100,"firmwareRevision":"97","id":"80:6F:B0:45:BF:81","name":"Polycom Remote","connected":true}]
Batch File option using CURL
using a local file called IP_Pass.txt with the IP address and the password comma separated and create a Windows Batch File with the following content to reboot a Studio X or G7500
@echo off
echo Reading IP_Pass.txt
for /F "tokens=1,2 delims=," %%a in (IP_Pass.txt) do (
curl -b cookies.txt -c cookies.txt -X POST -d "{\"user\": \"admin\"="\"password\": \"%%b\"}" -H "Content-Type: application/json" -k https://%%a/rest/session
curl -b cookies.txt -c cookies.txt -H "Content-Type: application/JSON" -k https://%%a/rest/system/reboot
timeout /t 5 /NOBREAK
)
Power Shell examples
reboot an individual Poly Studio X or G7500 itself using a hardcoded IP and Password:
#BEGIN POWERSHELL SCRIPT FOR POLY G7500 REST command
$password = "789" #your password
$IP = "192.168.0.92" #IP of unit
#URL to make new session
$sessionURL = ("https://" + $IP + "/rest/session");
#Command to make new session
$sessionBody = "{`"user`": `"admin`",`"password`": `"" + $password + "`"}"
#URL to issue reboot
$rebootURL = ("https://" + $IP + "/rest/system/reboot");
#Command to issue reboot
$rebootBody = "{`"action`": `"reboot`"}"
# disable self signed certificate check
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors
)
{
return true;
};
}
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]::Ignore()
# End self signed certificate commands
Invoke-WebRequest $sessionURL -UseBasicParsing -ContentType "application/json" -Method Post -body $sessionBody -SessionVariable sess;
Invoke-WebRequest $rebootURL -UseBasicParsing -ContentType "application/json" -Method Post -WebSession $sess -Body $rebootBody
reboot an individual Poly Studio X or G7500 with all attached devices using a hardcoded IP and Password:
#BEGIN POWERSHELL SCRIPT FOR POLY G7500 REST command
$password = "789" #your password
$IP = "172.19.141.52" #IP of unit
#URL to make new session
$sessionURL = ("https://" + $IP + "/rest/session");
#Command to make new session
$sessionBody = "{`"user`": `"admin`",`"password`": `"" + $password + "`"}"
#URL to issue reboot
$rebootURL = ("https://" + $IP + "/rest/system/reboot");
#Command to issue reboot
$rebootBody = "{`"action`": `"reboot`" , `"restartAll`": `"True`"}"
# disable self signed certificate check
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors
)
{
return true;
};
}
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]::Ignore()
# End self signed certificate commands
Invoke-WebRequest $sessionURL -UseBasicParsing -ContentType "application/json" -Method Post -body $sessionBody -SessionVariable sess;
Invoke-WebRequest $rebootURL -UseBasicParsing -ContentType "application/json" -Method Post -WebSession $sess -Body $rebootBody
reboot multiple Poly Studio X or G7500 without attached devices using a Text File with the IP Address and Password at c:\temp\restapi\IP_Pass.txt
#BEGIN POWERSHELL SCRIPT FOR REBOOTING Poly GroupSeries command
$File = get-content "c:\temp\restapi\IP_Pass.txt"
foreach ($line in $File){
$Arr = $line.Split(',')
[array]
#URL to make new session
$sessionURL = ("https://" + $Arr[0] + "/rest/session");
#Command to make new session
$sessionBody = "{`"user`": `"admin`",`"password`": `"" + $Arr[1] + "`"}"
#URL to issue reboot
$rebootURL = ("https://" + $Arr[0] + "/rest/system/reboot");
#Command to issue reboot
$rebootBody = "{`"action`": `"reboot`"}"
# disable self signed certificate check
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors
)
{
return true;
};
}
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]::Ignore()
# End self signed certificate commands
Invoke-WebRequest $sessionURL -UseBasicParsing -ContentType "application/json" -Method Post -body $sessionBody -SessionVariable sess;
Invoke-WebRequest $rebootURL -UseBasicParsing -ContentType "application/json" -Method Post -WebSession $sess -Body $rebootBody
}
The IP_Pass.txt file is just a comma-separated file with the IP,Password
EagleEye Director II API
REST API Info >here<
If official support is required please check how to phone or open a case here
----------------