CISCO xAPI - GET and PUT Requests

I refer to myself as a “cut-&-paste programmer” - I know enough to be dangerous. Google is an excellent source of information and, if you understand the basics, you can piece together code to do almost anything. So - here we go….

This first blog is to just set the stage for using VBScript and the xAPI to interact with a CISCO endpoint. I am accessing the CISCO endpoint API using HTTPS - CISCO refers to it as XMLAPI. With this API you use POST requests to tell the endpoint to do something or to change a configuration and GET requests to get configuration or status information from the endpoint.

For either POST or GET - your script makes a connection to the endpoint, authenticates and returns the results.

Steps involved in VBScript:

Endpoint Info for Examples
Endpoint IP - 192.168.2.11
Authentication User - apiuser
Authentication Password - supersecretpassword

  1. Create the Msxml2.ServerXMLHTTP.6.0 object

  2. Open the connection to the endpoint using either POST or GET

  3. Set the Request Headers

  4. Send the API Commands

  5. Display the response

The script examples below are very basic and do not do any formatting of the responses so you can get an idea of what is sent to the endpoint and what the results look like.

XML POST REQUEST EXAMPLE

This is an script that uses a POST request to initiate a call from the endpoint to the BlueJeans Test Site.

The API commands are XML formatted.

<Command><Dial>
<Number>111@199.48.152.152</Number><Protocol>SIP</Protocol>
</Dial></Command>

The API commands can be found on the support.cisco.com site or by browsing to the commands.xml page from the endpoint.

https://<endpointIP>/command.xml

'====  EXAMPLE FOR MAKING A CALL ====
'1. Create the XMLHttp Object
Set xmlHTTP = CreateObject("Msxml2.ServerXMLHTTP.6.0")
'2. Make the Connection to the Endpoint
xmlHTTP.setOption 2, 13056 'Required to ignore certificate errors
xmlHTTP.Open "POST", "https://192.168.0.1/putxml", false, “apiuser”, “supersecretpassword”
'3. Set the Request Header
xmlHTTP.setRequestHeader "Content-Type", "text/xml"
'4. Send the API commands
xmlHTTP.send "<Command><Dial><Number>111@199.48.152.152</Number><Protocol>SIP</Protocol></Dial></Command>"
'5. Display the Response from the API command
MsgBox xmlHTTP.responseText

xml POST RequesT Example

This is example of a scripted POST request that will return whether the endpoint is muted or not.

You can see the open request is a GET and includes the path to the status information you want, in this case the status of the Microphones.

For a list of the all of the status information you can collect off the endpoint - you can get the status.xml page from the endpoint in a browser.

https:/<endpointIP>/status.xml

'==== EXAMPLE FOR CHECKING MUTE STATUS ====
'1. Create the XMLHttp Object
Set xmlHTTP = CreateObject("Msxml2.ServerXMLHTTP.6.0")
'2. Make the Connection to the Endpoints
xmlHTTP.setOption 2, 13056 ' Required to ignore certificate errors
xmlHTTP.Open "GET", "https://192.168.2.11/getxml?location=/Status/Audio/Microphones", false, "apiuser","supersecretpassword"
'3. Set the Request Headers
xmlHTTP.setRequestHeader "Content-Type", "text/xml"
'4. Send the API Commands
xmlHTTP.send
'5 Display the Response from the API command
MsgBox xmlHTTP.responseText

You will see the the msgbox at the end of the script shows the XML representation of the status of the microphones including the Mute value.

In the image of the msgbox here - you can see Mute is ON.



muteSTATUS.png