Plantronics + Polycom. Now together as Poly Logo

Reboot a Poly Studio X30 via REST API

CyPh3R
Occasional Contributor

Reboot a Poly Studio X30 via REST API

Dear Community,

I'm trying to implement a support PowerShell script to reboot a Poly Studio device using the REST API. Based from some forum threads (e.g. https://community.polycom.com/t5/VoIP-SIP-Phones/FAQ-REST-API/td-p/98914) and the Poly REST API Reference Guide I forged following script to call a reboot of a certain device using a Basic Auth.

 

#Credentials

$username = "admin"
$password = "******************" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)


#Certificate and TLS settings
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
    ServicePoint srvPoint, X509Certificate certificate,
    WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

# Set Tls versions
$allProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $allProtocols


#Body for REST API call
$body = @"
{
 `"action`": `"reboot`"
}
"@


#Invoke REST command

Invoke-RestMethod -Uri "https://IP_OF_THE_POLY_DEVICE/rest/system/reboot" -Credential $cred  -Method Post -ContentType "application/json" -Body $body  

 

 

But running the script brings a 403 Error:

 

"Invoke-RestMethod :
Status page
Forbidden
The server understood the request, but is refusing to fulfill it
You can get technical details here.
Please continue your visit at our home page.
In Zeile:31 Zeichen:2
+ Invoke-RestMethod -Uri "https://xxx.xxx.xxx.xxx/rest/system/reboot" -Cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"

 

I have no clue how to successfully authenticate to the device with the admin credentials of the Poly Studio and then perform the reboot command. Has anyone an idea what I am missing here? Any help is greatly appreciated.

 

Kind Regards,

Torsten

Message 1 of 4
3 REPLIES 3
SteffenBaierUK
Polycom Employee & Community Manager

Re: Reboot a Poly Studio X30 via REST API

Hello @CyPh3R ,

 

Welcome back to the Poly Community.

Both the communities Must Read First or Read 1st and if available the FAQ reference the basic minimum information a new or follow up post should contain.

This ensures the questions having to be asked are limited and any new or follow up post contains the right amount of details to ensure any voluntary participant within the community does not spend additional time chasing basic information.


Unfortunately, your post fell a bit short of the above-explained requirements and we kindly ask you, therefore, to ensure to read these sections and ensure a reply (not Edit!) provides as much detail as possible

 

Statting the above please ensure you check:

 

May 19, 2020 Question: Does a Poly G7500 or Studio X50/X30 support REST API?
Resolution: Details on this can be found in the Poly VideoOS REST API Reference Guide >here< (or search the Support Page for the latest) or for instructions check >here<

 

Another community member also posted this >here<


Please ensure to provide some feedback if this reply has helped you so other users can profit from your experience.

Best Regards

Steffen Baier

 

----------------
The title Poly Employee & Community Manager is a community setting and does not reflect my role. I am just a simple volunteer in the community like everybody else. All posts and words are my own & do not represent the views of Employer.

----------------

Notice: This community forum is not an official Poly support resource, thus responses from Poly employees, partners, and customers alike are best-effort in attempts to share learned knowledge. If you need immediate and/or official assistance please open a service ticket through your proper support channels.
Please also ensure you always check the VoIP , Video Endpoint , Skype for Business , PSTN or RPM FAQ's
Message 2 of 4
CyPh3R
Occasional Contributor

Re: Reboot a Poly Studio X30 via REST API

Hello @SteffenBaierUK,

thank you for your reply. It looks like my searching and finding skills are not as good as yours, since I was not able to find the thread you mentioned. BUT, this thread was a full hit to guide me into the right direction!

 

Using curl with the "cookies.txt "to connect and reboot the device did the job. I even adapted this method into a little PowerShell script. So for other users who may have the same question in the future, maybe this will help:

 

 

#Set variables fur Curl
$CurlEXE            = 'C:\Windows\System32\curl.exe'

$CurlArgument_logon = '-b', 'c:\temp\cookies_my_poly_device.txt',
                      '-c', 'c:\temp\cookies_my_poly_device.txt',
                      '-d', '{\"user\": \"admin\",\"password\": \"123\"}',
                      '-H', 'Content-Type: application/json',
                      '-k', 'https://10.20.30.44/rest/session'


$CurlArgumentReboot = '-b', 'c:\temp\cookies_my_poly_device.txt',
                      '-c', 'c:\temp\cookies_my_poly_device.txt',
                      '-H', 'Content-Type: application/json',
                      '-k', 'https://10.20.30.40/rest/system/reboot',
                      '-d', '{\"action\": \"reboot\"}'
                

#Logon and reboot device
& $CurlEXE @CurlArgument_logon
& $CurlEXE @CurlArgumentReboot

 

Thank you very much for the hint!

 

Kind Regards,

Torsten

 

Message 3 of 4
SteffenBaierUK
Polycom Employee & Community Manager

Re: Reboot a Poly Studio X30 via REST API

Hello @CyPh3R ,

 

there is already a working Power Shell script >here<

 

Please ensure to provide some feedback if this reply has helped you so other users can profit from your experience.

Best Regards

Steffen Baier

----------------
The title Poly Employee & Community Manager is a community setting and does not reflect my role. I am just a simple volunteer in the community like everybody else. All posts and words are my own & do not represent the views of Employer.

----------------

Notice: This community forum is not an official Poly support resource, thus responses from Poly employees, partners, and customers alike are best-effort in attempts to share learned knowledge. If you need immediate and/or official assistance please open a service ticket through your proper support channels.
Please also ensure you always check the VoIP , Video Endpoint , Skype for Business , PSTN or RPM FAQ's
Message 4 of 4