Plantronics + Polycom. Now together as Poly Logo

Formating REST API Post in Python

Jim-D
Occasional Visitor

Formating REST API Post in Python

I'm trying to send a POST request to restart a phone using python:requests-module to the API and getting either "400 Bad Request" or "4000 Invalid input parameters.

This is the request.

reb = requests.post('https://10.10.10.10/api/v1/mgmt/safeReboot', json, auth=('username','password'),)

 

Not sure what I'm missing, but any help is appreciated.

 

I got this from the following document.

Using the "ucsoftware-restapi.pdf",

Management.Restart

Protocol, Method & Path

Protocol: HTTP/HTTPS

Method: POST
Path: /api/v1/mgmt/safeRestart

 Input / Output Format Access Level

JSON

Input

None

Output

Applicable return codes

Success Response:

{“Status”: “2000” }

Failure Response:

{ “Status”: “5000” }

2000, 5000

 

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

Re: Formating REST API Post in Python

Hello @Jim-D ,

 

Welcome to the Poly Community.


The Voice FAQ contains:

 

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

Resolution: Please => here <=

 

the above has examples that you can use and work your way back.

 

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. My official "day" Job is 3rd Level support at Poly but I am unable to provide official support via the community.

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

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 8
Jim-D
Occasional Visitor

Re: Formating REST API Post in Python

Thank you for your response, I've read those documents and they only say post "None" or nothing to the url - https://x.x.x.x/api/v1/mgmt/safeRestart

 

I'm sending:

reb = requests.post('https://x.x.x.x/api/v1/mgmt/safeReboot', "Content-Type: application/json", auth=('username','password'))

keep getting code 400 or 4000. I can issue a GET request, but for some reason I can't sent a POST. I'm not using powershell.

 

Any help is appreciated.

Thanks,

Jim-D,

 

Message 3 of 8
Jim-D
Occasional Visitor

Re: Formating REST API Post in Python

In case it helps,

Phone Information

Phone Model: VVX 501

UC Software Version: 5.8.1.7278

Updater Version: 5.9.6.8818

 

 

Message 4 of 8
SteffenBaierUK
Polycom Employee & Community Manager

Re: Formating REST API Post in Python

Hello @Jim-D 

 

you are using an unsupported software. Update to a currently supported software for your phone model and then test one of the examples. CURL or Power Shell and then you can work your way back with Python

 

replied via a mobile device 

----------------
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. My official "day" Job is 3rd Level support at Poly but I am unable to provide official support via the community.

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

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 5 of 8
Jim-D
Occasional Visitor

Re: Formating REST API Post in Python

Thanks for the suggestion. Unfortunately this is the version of software on the 2000+ phones. I can not change that at this time.

 

I did try the powershell commands on a test windows pc and it does work, so I know the phones will respond to a saferestart api request. What I need help with is how to put that into a python request so the phone will do the same thing.

 

Thanks,

Jim-D,

 

Message 6 of 8
Jim-D
Occasional Visitor

Re: Formating REST API Post in Python

Figured it out.

reb = requests.post('https://x.x.x.x/api/v1/mgmt/safeRestart', headers={'Content-Type' : 'applicaation/json'}, auth=('username','password'), verify=False)

I appeciate your help.

 

Jim-D,

 

Message 7 of 8
Spam649
Occasional Visitor

Re: Formating REST API Post in Python


Thanks for the update and quick reply. I'll be sure to keep an eye on this thread.  Bumped into your thread. Thanks for creating it. Looking forward for solution.

Message 8 of 8