REpresentational State Transfer, commonly abbreviated as REST, is a software architectural style that defines a set of constraints to be used for creating web services. This allows for rapid communication between networking applications and devices, with consistent inputs and outputs and predictable results.
What is an API?
An Application Programming Interface (API) is a set of routines, protocols, and tools to define interactions between software applications.
The Aruba AOS-CX REST API is known as such because it is an API that conforms to REST standards.
To learn more about REST API, check out the Aruba Bots YouTube video below.
In order for the AOS-CX device to receive and process API calls, a few requisite commands must first be executed on the switch to enable API access.
- There must be a user on the switch who belongs to the "administrators group" and has a password set. This user would then be allowed to access the REST API. In the below example, replace the username "admin" and password "mypassword" with your own username and password respectively.
8320(config)# user admin group administrators password plaintext mypassword
- The switch must have the access mode for the HTTPS server set to either "read-only" or "read-write." By default, the switch's HTTP server is set to "read-only" mode, which allows only GET requests, with the exception of a few POST/PUT methods (see here for specifics). To utilize the API calls for DELETE, PUT, and POST, execute the below command with "read-write" mode specified.
8320(config)# https-server rest access-mode read-write
- The HTTPS server must be enabled on the VRF through which the client making the API requests can reach the switch.
8320(config)# https-server vrf default 8320(config)# https-server vrf mgmt
As of v10.04 by default, REST access-mode is set to read-write on the default VRF.
Going forward, the REST call examples will use cURL, which is an open-source command-line interface tool.
More information on cURL can be found in the cURL subsection of the Additional Resources page.
The AOS-CX REST API utilizes a cookie to keep session state information. This session cookie is encrypted and contains session-specific data.
To log in to an AOS-CX device through the API, make a REST call using cURL, Postman, the Python requests library, or any other tool that supports the execution of a POST request. An example using cURL is shown here:
curl -X POST "https://192.168.1.1/rest/v10.04/login?username=admin&password=mypassword"
To log out of an AOS-CX device through the API, a similar POST call must be made, except to a different URI. An example using cURL is below:
curl -X POST "https://192.168.1.1/rest/v10.04/logout"
Updated 8 months ago