Plantronics + Polycom. Now together as Poly Logo

Reboot or Factory reset VVX phones using submit-form POST method is not working

afahmy
Occasional Contributor

Reboot or Factory reset VVX phones using submit-form POST method is not working

Hello folks,

I am trying to automate reboot and factory reset polycom VVX phones using the submit-form/Reboot in the below code ( I'm verifying functionality on one phone then i have another script to iterate through a list of phones).

 

import requests

url = "https://<ip-address>/form-submit/Reboot"

headers = {
'Authorization': 'Basic UG9seWNvbTphZG1uODAyNzk5NTE4MDEwcHdk'
}

response = requests.request("POST", url, headers=headers, verify=False)

print(response.text)

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

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head><title>401 Unauthorized</title></head><body>
Authorization failed.
</body></html>

 

Process finished with exit code 0

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

I am 100% sure of the authorization in the headers because i can use it with POST method to login to the polycom phone

 

import requests

url = "https://<ip-address>/form-submit/auth.htm"

headers = {
'Authorization': 'Basic UG9seWNvbTphZG1uODAyNzk5NTE4MDEwcHdk'
}

response = requests.request("POST", url, headers=headers, verify=False)

print(response.text)

lockparams|SUCCESS|0

Process finished with exit code 0

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

So i am not sure why it is not authorizing me to make the Reboot or factory reset functions?

 

In other posts for different phones series i tried the Curl commands to do the same but also this gives the same results (using Postman, Python script, or Curl Command). any suggestions would be appreciated.

 

Phone model: VVX201

UC Software Version 6.3.0.14929

Updater Version 6.3.0.6751

 

Note: i don't want to make the Reboot or Factory reset using REST API as there are constraints prevents me from using it, however i verified it is working properly.

 

Regards, Ahmed

Message 1 of 7
6 REPLIES 6
SteffenBaierUK
Polycom Employee & Community Manager

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

Hello @afahmy ,

 

Welcome to the Poly Community.

 

A Perl script I have used in the past:

#!/usr/bin/perl -w
# RebootScript.pl - Reboot range of Polycom phones using the Web Interface
# Initial Script (???) - bm
# Updated (???) - sb
# Update (28 April 2017) - mcab
# 	- Set the admin username and password at the top of the file. (Script will generate the cookie automatically now)
# 	- Removed dependency on CGI.pm
# Update (28 April 2017 #2) - mcab
# 	- add IO::Socket::SSL
# 	- ignore validating TLS certs from phone
# Update (5 June 2017) - mcab
# 	- Added reset to factory defaults

use strict;
use LWP::UserAgent;
use IO::Socket;
use Socket; 
use IO::Socket::SSL;
use MIME::Base64;

my $username = "Polycom";
my $password = "789";

#####################################
# Netmask 255.255.255.0	= 0xFFFFFF00#
# Netmask 255.255.0.0	= 0xFFFF0000#
# Netmask 255.0.0.0		= 0xFF000000#
# Netmask 0.0.0.0		= 0x00000000#
#####################################

my $netmask = 0xFFFFFF00; # 255.255.255.0

#########################################
# Define IP Address Start Range	$Start	#
# Define IP Address End Range $finish	#
#########################################

my $start_address = unpack 'N', inet_aton( '10.252.149.57' );
my $finish_address = unpack 'N', inet_aton( '10.252.149.58' );


for ( my $address = $start_address; $address <= $finish_address; ++$address ) {
next if ( $address & $netmask ) == $address or ( $address & ~$netmask ) == ~$netmask;


my $ua = LWP::UserAgent->new( );
$ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => SSL_VERIFY_NONE );
my $destination = inet_ntoa( pack 'N', $address);

#############################
# Define Reboot or Restart  #
# Simply remove # and add # #
#############################

#my $restartUrl = "http://$destination/form-submit/Restart";
my $restartUrl = "https://$destination/form-submit/Reboot";
#my $restartUrl = "https://$destination/form-submit/Utilities/restorePhoneToFactory";
  
# Create request object and add the authentication header and the expected cookie
  my $req =  HTTP::Request->new(POST => $restartUrl);
  $req->header('Cookie' => 'Authorization=Basic ' . encode_base64("$username:$password"));
  $req->authorization_basic( $username, $password );
 
 
# Send the reset request to the user agent
  my $res = $ua->request( $req );
  print $res->status_line, "\n";
  sleep (5)
}

 

The password is hardcoded and simply move the # and replace for the action wanted.

 

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 Polycom 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 7
twelve_zeros
Occasional Visitor

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

I'm also having this issue. I can turn on the REST api and it works via curl example:

 

curl -k -X POST -H "Content-Type: application/JSON" -H 'Content-Length: 0' https://Polycom:456@10.100.100.100/api/v1/mgmt/safeReboot

 

I can't work with a vvx150 when using another example:

 

curl -k 'https://10.100.100.100/form-submit/Reboot' -X POST -H 'Authorization: Basic base64String' -H 'Content-Length: 0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: Authorization=Basic base65String'
Message 3 of 7
SteffenBaierUK
Polycom Employee & Community Manager

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

Hello @twelve_zeros ,

 

Welcome to the Poly Community.

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

 

Your post does not include the above clearly outlined information.


In regards to the Rest API please see our FAQ:

 

Jun 05, 2018 Question: Do Poly Phones support a REST API?

Resolution: Please => here <=

 

There are multiple working examples contained in the above

 

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 Polycom 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 7
twelve_zeros
Occasional Visitor

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

While the original poster has not replied, I can attest that your provided script does not work. I should have made it clear. I created this account just for this reason. I don't know if you have a curl example to also try, perl is very old and is not used much these days.

 

I'm working with a VVX150 on 5.9.6.2996

I can test on newer firmware and different models, but I want to say I read somewhere past v6 that these phones no longer support submit-form process - which could be why this person here is having issues.

Message 5 of 7
SteffenBaierUK
Polycom Employee & Community Manager

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

Hello @twelve_zeros ,

 

I believe we use cookies and/or Referer: header so I believe this is the reason for this no longer working.

 

I have a newer version a colleague created but I don't feel comfortable posting this. The REST API FAQ has examples of how to utilize batch processing with Curl so it should cover this.

Best Regards

Steffen Baier

----------------
The title Polycom 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 6 of 7
Diego_A
Polycom Employee

Re: Reboot or Factory reset VVX phones using submit-form POST method is not working

Hi Team!

 

I hope that this code helps you. It's on Powershell

You need to create a cokie and include at the header of the request

 

 

 

 

$Protocol = "http"

$IP = "000.000.000.000"

$PW = "0000"



$pair = "Polycom:$($PW)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))



$session2 = New-Object Microsoft.PowerShell.Commands.WebRequestSession

$session2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"

$session2.Cookies.Add((New-Object System.Net.Cookie("Authorization", "Basic $($encodedCreds)", "/", $IP)))



$InvokeReset = Invoke-WebRequest -UseBasicParsing -Uri "$($Protocol)://$($IP)/form-submit/Utilities/restorePhoneToFactory" `

-Method "POST" `

-WebSession $session2 `

-Headers @{

"Authorization"="Basic $($encodedCreds)"

"Accept"="*/*"

"Origin"="$($Protocol)://$($IP)"

"Referer"="$($Protocol)://$($IP)"

"Accept-Encoding"="gzip, deflate"

"Accept-Language"="en-US,en;q=0.9"

} `

-ContentType "application/x-www-form-urlencoded"

 

 

 



I hope it helps you

Message 7 of 7