Using xAPI via HTTP
Let's see how you can interact will with xAPI via HTTP.
xAPI Guide > Using xAPI via HTTP
The xAPI HTTP protocol details are documented in your device’s API Reference Guide, as shown on page 43 of RoomKit's Reference Guide 9.5, for example:
Basically:
- Your device exposes an HTTP/HTTPS server for REST API requests
- Data are exchanged as
text/xml
payloads, and Basic Auth is used for authentication - The
/getxml?location=
URI path is used to retrieve status information - The
/putxml
URI path lets you POST configuration and command requests
anchorPrerequisites and Configuration
anchorIMPORTANT: Before continuing, please make sure you have followed the instructions in Prerequisites and Configuration.
anchorRetrieve the current value of the device's standby status via HTTP
anchorIn the steps below, you will need to specify user credentials in the Authorization
header. xAPI requires these credentials be in the Basic Authentication standard format. For this tutorial, we have pre-generated the Authorization
header value for you, based on the 'integrator:integrator' username and password: Basic aW50ZWdyYXRvcjppbnRlZ3JhdG9y
If you are using a different username/password combination, you can use an online service such as Base64Encode to encode the 'username:password' combo (note the required :
).
Or, on a Mac/Linux system, you can also generate this password with the following terminal command:
echo -n "myuser:mypassword" | base64
For cURL users
cURL is a flexible command line tool for making HTTP requests. If you have cURL available on your PC, open a terminal and enter the command below (replacing with your device’s IP address and credentials, if different):
curl --insecure -X GET "https://{device_ip}/getxml?location=/Status/Standby" -u myuser:mypassword
this should return something like:
<?xml version="1.0"?>
<Status product="Cisco Codec" version="ce9.3.0.344d3cf" apiVersion="4">
<Standby>
<State>Standby</State>
</Standby>
</Status>
Notice how the information returned is similar to what you saw via SSH, though in XML format.
For Postman users
Postman has a nice GUI for testing and playing with HTTP and REST APIs.
In Postman, go ahead and create/send a new GET
request pointed at your device’s https://{device_ip}/getxml?location=/Status/Standby
endpoint, with an Authorization header value: Basic aW50ZWdyYXRvcjppbnRlZ3JhdG9y
Note: by default Postman enables 'SSL certificate verification', which will likely prevent connecting to your device due to a self-signed-certificate. You can temporarily change this setting.
You should receive an XML response body similar to what you got from cURL above.