Monitoring, Management & Location Tracking

Accessing the Airwave XML API using curl

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:

# curl -k -c /tmp/cjar -d "credential_0=admin" -d "credential_1=admin" -d "destination=/" -d "login=Log In" https://10.162.117.19/LOGIN


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:

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
 
10.162.117.19FALSE/TRUE1379056574Mercury::Handler::AuthCookieHandler_AMPAuthb4c3282201774765b209bee0ca1287a8

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.xml

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.

 

Verification :

Below is an example showing the ap_detail.xml page being accessed with curl.

[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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="/">here</a>.</p>
<hr>
<address>Apache Server at localhost.localdomain Port 80</address>
</body></html>
[root@localhost mercury]# cat /tmp/cjar
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
 
10.162.117.19FALSE/TRUE1379056574Mercury::Handler::AuthCookieHandler_AMPAuthb4c3282201774765b209bee0ca1287a8
[root@localhost mercury]# curl -k -b /tmp/cjar --output /tmp/ap_detail.xml https://10.162.117.19/ap_detail.xml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 88199  100 88199    0     0   104k      0 --:--:-- --:--:-- --:--:--  112k
[root@localhost mercury]# cat /tmp/ap_detail.xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<amp:amp_ap_detail version="1" xmlns:amp="" xmlns:xsi="" xsi:schemaLocation=" amp_ap_detail.xsd">
  <ap id="4">
    <ap_folder>Top</ap_folder>
    <ap_group>Access Points</ap_group>
    <interface id="12">
      <admin_status>Up</admin_status>
      <avg_bw_in>0.00</avg_bw_in>
      <avg_bw_out>0.00</avg_bw_out>
      <description>GE1/3</description>
      <mac_address>00:0B:86:6E:27:04</mac_address>
      <name>GE1/3</name>
      <oper_status>Down</oper_status>
      <port_index>3</port_index>
..output truncated...

 

Version History
Revision #:
1 of 1
Last update:
‎07-17-2014 07:12 AM
Updated by:
 
Labels (1)
Contributors
Search Airheads
Showing results for 
Search instead for 
Did you mean: 
Is this a frequent problem?

Request an official Aruba knowledge base article to be written by our experts.