Introduction : One of the first steps to using the Airwave XML API is accessing the data using an easily scriptable method. This article will explain how to obtain data from the Airwave XML API using the curl program. You can also apply this method to use wget or other utilities to access the Airwave XML API but it will require some minor syntax changes.
Answer : To access the Airwave XML API pages you must first establish a session and obtain a cookie. This can be done using a combination of the "cookie jar" (-c) and "data" (-d) arguments within curl.
Note that the "-k" flag is also specified. This will ignore any certificate warnings and is an optional flag if you are experiencing issues with self-signed certificate warnings.
Example session command:
This command will attempt to post credential_0=admin, credential_1=admin to the LOGIN page on the 10.162.117.19 server and save the resulting cookie to the /tmp/cjar file.
Note that credential_0 should be set to equal your username, and credential_1 should be set to equal your password.
Example contents of /tmp/cjar file:
Our client is now "logged in" to the server as we have a session cookie to use with the next command.
Now the "-b" argument is used to specify a cookie jar to use with our request, in this case /tmp/cjar. Also the --output argument is specified with a parameter of /tmp/ap_detail.xml which is where the output from the command will be saved.
Example API query command:
# curl -k -b /tmp/cjar --output /tmp/ap_detail.xml https://10.162.117.19/ap_detail
At this point a successful query to the Airwave XML API has been made using curl with the output saved to /tmp/ap_detail.xml for further processing. Simply alter the final command's destination from (https://10.162.117.19/ap_detail.xml) to (https://10.162.117.19/file.xml?argument=value) for making more complex queries. Detailed instructions are in the Airwave XML API guide found in the Airwave User Guide which can be downloaded from support.arubanetworks.com.
[root@localhost mercury]# curl -q -k -c /tmp/cjar -d "credential_0=admin" -d "credential_1=admin" -d "destination=/" -d "login=Log In" https://10.162.117.19/LOGIN