Rest v1
Rest v1
10 REST v1 API
Guide
All AOS-CX Series Switches
|2
Notices
The information contained herein is subject to change without notice. The only warranties for Hewlett
Packard Enterprise products and services are set forth in the express warranty statements
accompanying such products and services. Nothing herein should be construed as constituting an
additional warranty. Hewlett Packard Enterprise shall not be liable for technical or editorial errors or
omissions contained herein.
Confidential computer software. Valid license from Hewlett Packard Enterprise required for possession,
use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer
Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government
under vendor's standard commercial license.
Links to third-party websites take you outside the Hewlett Packard Enterprise website. Hewlett Packard
Enterprise has no control over and is not responsible for information outside the Hewlett Packard
Enterprise website.
|5
Enabling the notifications subsystem on a switch 77
Establishing a secure WebSocket connection through a web browser 77
Establishing a secure WebSocket connection using a script 77
Subscribing to topics 78
Unsubscribing from topics 79
Parts of a subscribe message 80
Parts of a subscription success message 80
Parts of a notification message 82
Example: Browser-based WebSocket connection 84
Example: Getting information about current subscribers and subscriptions 87
Troubleshooting 90
General troubleshooting tips 90
REST API response codes 92
Error "'admin' password is not set" 93
Error "certificate verify failed" returned from curl command 93
HTTP 400 error "Invalid Operation" 94
HTTP 400 error "Value is not configurable" 94
HTTP 400 error "Reference failure" 95
HTTP 401 error "Authorization Required" 95
HTTP 401 error "Login failed: session limit reached" 96
HTTP 403 error "Forbidden" on a write request 96
HTTP 403 error "Forbidden" on a GET request 97
HTTP 404 error "Page not found" when accessing the switch URL 97
HTTP 404 error "Object not found" on object with "bridge/" in URI Path 97
HTTP 404 error "Object not found" returned from a switch that supports multiple REST API
versions (10.04 and later) 98
HTTP 404 error "Object not found" when using a write method 98
HTTP 404 error "Page not found" when using a write method 99
Logout fails 99
Applicable products
This document applies to the following products:
example-text Identifies commands and their options and operands, code examples,
filenames, pathnames, and output displayed in a command window. Items
that appear like the example text in the previous column are to be entered
exactly as shown and are required unless enclosed in brackets ([ ]).
| Vertical bar. A logical OR that separates multiple items from which you can
choose only one.
Any spaces that are on either side of the vertical bar are included for
readability and are not a required part of the command syntax.
… or Ellipsis:
... n In code and screen examples, a vertical or horizontal ellipsis indicates an
omission of information.
n In syntax using brackets and braces, an ellipsis indicates items that can be
repeated. When an item followed by ellipses is enclosed in brackets, zero
or more items can be specified.
For example, the logical interface 1/1/4 in software is associated with physical port 4 on the switch.
For example, the logical interface 1/1/4 in software is associated with physical port 4 on the switch.
For example, the logical interface 1/1/4 in software is associated with physical port 4 in slot 1 on
member 1.
For example, the logical interface 1/1/4 in software is associated with physical port 4 on member 1.
For example, the logical interface 1/3/4 in software is associated with physical port 4 in slot 3 on
member 1.
For example, the logical interface 1/1/4 in software is associated with physical port 4 on the switch.
If using breakout cables, the port designation changes to x:y, where x is the physical port and y is the lane when
split to 4 x 10G or 4 x 25G. For example, the logical interface 1/1/4:2 in software is associated with lane 2 on
physical port 4 in slot 1 on member 1.
For example, the logical interface 1/1/4 in software is associated with physical port 4 in slot 1 on
member 1.
REST v1 is deprecated with the the release of AOS-CX 10.09. Following AOS-CX 10.09, REST v1 will be hidden and
can be consulted, but it is no longer supported.
Starting with AOS-CX 10.08, the REST v1 API is deprecated. It is still active, but no new features were added with
10.08 and no new features will be subsequently added.
The Aruba 6000 Switch Series and 6100 Switch Series only support the default VRF and has no management port.
Therefore, references in this guide to other VRFs or the management port do no apply to the 6000 Switch Series
and 6100 Switch Series. Configuration for these switches should be done over an SVI having a physical port with
access to the SVI, since the physical ports in the 6000 and 6100 are not routed.
The Aruba 4100i Switch Series only supports the default VRF and has no management port. Therefore, references
in this guide to other VRFs or the management port do no apply to the 4100i Switch Series. Configuration for
these switches should be done over an SVI having a physical port with access to the SVI, since the physical ports in
the 4100i are not routed.
GET method
The GET method query parameters differ between REST v1 and REST v10.04:
n The REST v10.04 selector parameter includes a value of writable, which enables you to get only the
mutable attributes of a resource.
n The REST v1 depth parameter has a default of 0 and a range of 0 through 3.
The REST v10.04 depth parameter has a default of 1 and a range of 1 through 4. The REST v10.04
depth=1 is equivalent to the REST v1 depth=0, and so on.
Resource collections
In REST v10.04, the members of a resource collection are represented as JSON objects, where the key is
the index and the value is the URI of the resource.
For example, the response to a GET request to /rest/v10.04/system/vrfs is as follows:
{
"default": "/rest/v10.04/system/vrfs/default",
"mgmt": "/rest/v10.04/system/vrfs/mgmt"
}
In contrast, the response to a GET request to /rest/v1/system/vrfs on the same switch is as follows:
[
"/rest/v1/system/vrfs/default",
"/rest/v1/system/vrfs/mgmt"
]
The Aruba 6000 Switch Series and 6100 Switch Series only support the default VRF.
n read-write (default)
n read-only
The default read-write access mode is not displayed in the show running-configuration command.
You can change the access mode to read-only using the https-server rest access-mode read-only
CLI command from the global configuration (config) context. You can validate the mode set using the
show https-server command.
n The AOS-CX REST API Reference shows most of the supported read and write methods for all switch
resources.
n The REST API can access and change every configurable aspect of the switch as modeled in the
configuration and state database.
The REST API is powerful, but must be used with extreme caution: For most values, no semantic
validation is performed on the data that you write to the database, and configuration errors can
destabilize the switch.
n Most switch resources support only GET methods, but some resources allow PUT or POST methods.
For example, you can use POST to log into the switch, use PUT to upload a new running
configuration, or use POST to upload a new firmware version.
n For most switch resources, the AOS-CX REST API Reference does not show any write methods (POST,
PUT, and DELETE) the resource might support. To show those write methods, read-write mode must
be enabled.
Parts of a URI
The two main parts of a URI are the path and the (optional) query component.
URI prefix
The URI prefix is the system URL and REST API version information. This information is specific to a
particular switch and REST API version, and is the same for every REST API request to that switch.
Script writers often create a variable for the URI prefix. Using a variable enables the writer to update a
script or use the same script logic for a different switch by updating the value of the URI prefix variable.
The URI prefix contains the following:
Server URL
The web server address of the switch.
Examples:
n https://192.0.2.5
n https://10.17.0.1
n https://myswitch.mycompany.com
If Virtual Switching Extension (VSX) is enabled, you can access most resources of the peer switch from
this switch by adding /vsx-peer in the URI path between the server URL and /rest. For more
information about VSX, see VSX peer switches and REST API access.
For example:
GET https://192.0.2.5/vsx-peer/rest/v1/system/vsx?attributes=oper_status
REST API and version identifier
For example: /rest/v1
Path parameters
A path parameter is a part of the URI path that can vary. Typically path parameters indicate a specific
instance of a resource in a collection, such as a specific VLAN in the vlans collection. The path can
contain several path parameters. Path parameters are indicated by braces {}.
For example, the AOS-CX REST API Reference displays the resource for specific VLAN as the following:
/system/vlans/{id}
When you send a request for VLAN 10, the URI you provide must substitute the VLAN ID, 10, for the {id}
query parameter. For example:
/system/vlans/10
In the AOS-CX REST API Reference, you enter the value of the path parameter in the Value field of the id
parameter.
Query component
In many cases, the unique identification of a resource requires a URI that contains both a path and a
query component. The query component is sometimes called the query string.
For example, CPU utilization is a resource represented by the following URI:
https://192.0.2.5/rest/v1/system/subsystems/management_module,1%2F5?attributes=resource_
utilization
In a URI, the question mark (?) indicates the beginning of the query component. The query component
contains nonhierarchical data, and the format of the query string depends on the implementation of
the REST API.
Resources
In a REST API, the primary representation of data is called a resource. A resource is a representation of
an entity in the system as a URI. The entities can include hardware objects, statistical information,
configuration information, and status information. The URI might or might not include a query
component. Resources are nouns—anything that can be named can be a resource.
Examples of resources:
n /system/vlans
n /system/users
n /fullconfigs
A GET request to a collection returns the set of JSON objects representing the members of the
collection. The following curl example shows the GET request and response returned for the vlans
collection:
Subcollections
A single resource instance can also contain subcollections of resources.
/system/vrfs/default/routes
Singletons
There are some resources that can only have one instance. These resources are called singletons and
the resource collection name is in the singular form.
For example:
n /system
n /system/vsx
n /firmware
Because there is only one resource in a singleton collection, GET requests return the JSON
representation of the resource instead of a URI list of one item. In addition, you do not need to supply a
resource ID in the URL of a GET request. For example, the following GET request to the firmware URI
returns the JSON data that represents the firmware resource:
Configuration attributes
Configuration attributes represent user-owned data. Although an attribute must be in the configuration
category to be modified by a user, not all attributes in the configuration category can be modified after
the resource instance is created. Configuration attributes that cannot be changed after the resource is
Writable attributes
Writable attributes are the subset of configuration attributes that are mutable. Writable attributes can
be modified by a user after the resource is created. When using the PUT method to modify a resource,
only writable attributes can be included in the request body.
In REST v10.04 and later versions, the GET method selector parameter includes a value of writable,
which enables you to get only the mutable configuration attributes of a resource.
Status attributes
Status attributes contain system-owned data such as the admin account and various status fields. You
cannot create or modify instances of attributes in this category.
Statistics attributes
Statistics attributes contain system-owned data such as counters. You cannot create or modify instances
of attributes in this category.
Prerequisites
n You must be in the global configuration context: switch(config)#.
n The password for the admin user must be configured on the switch.
Procedure
Enable HTTPS server access for the specified VRF.
For example:
n To enable access on all data ports on the switch, specify the default VRF:
The Aruba 6000 Switch Series and 6100 Switch Series only support the default VRF.
n To enable access on the OOBM port (management interface IP address), specify the management VRF
(not applicable to the 6000 and 6100):
n To enable access on ports that are members of the VRF named vrfprogs, specify vrfprogs:
If the switch responds with the following error, the admin user must have a valid password:
Failed to enable https-server on VRF mgmt. 'admin' password is not set
The switch is shipped from the factory with a default user named admin without a password. The admin
user must set a valid password before HTTPS servers can be enabled.
This session is valid only to change the admin password and logout from the REST API UI. Any other request will
return a Forbidden code (403).
Use the following API to change the admin password. Ellipses (...) represent data not included in the
example.
PUT /rest/v1/system/users/admin
{
...
"password": "<enter the password>"
...
}
After the password is changed successfully, the session restriction is removed.
The REST API in read-write mode can access every configurable element in the database. The REST API is powerful,
but must be used with extreme caution: For most values, no semantic validation is performed on the data that you
write to the database, and configuration errors can destabilize the switch.
Setting the access mode is independent from enabling or disabling access to the REST API.
Prerequisites
You must be in the global configuration context: switch(config)#.
Procedure
Set the REST API access mode to read-write.
The Aruba 6000 Switch Series and 6100 Switch Series only support the default VRF.
The Aruba 4100i Switch Series only supports the default VRF.
The command output lists the VRFs on which access to REST API is enabled and shows the current REST
API access mode.
If access is not enabled on any VRF, the VRF configuration is displayed as <none>.
For example:
Prerequisites
You must be in the global configuration context: switch(config)#.
Procedure
Disable HTTPS server access for the specified VRF by using the no form of the https-server vrf
command.
For example, the following command disables REST API access on the switch data ports in the default
VRF:
You can use the show https-server command to show the current configuration:
VRF : mgmt
REST Access Mode : read-write
Description
Sets the maximum amount of concurrent open sessions for any given user through the HTTPS server.
The amount of concurrent open sessions may have an impact on system performance, so it is
recommended to set this value to the minimum necessary.
Parameter Description
Example
Set the maximum number of concurrent user sessions to the maximum of 8:
Command History
Release Modification
Command Information
All platforms config Administrators or local user group members with execution
rights for this command.
Description
Changes the REST API access mode. The default mode is read-write.
Parameter Description
read-write Selects the read/write mode. Allows POST, PUT, PATCH, and
DELETE methods to be called on all configurable elements in the
switch database.
Usage
Because the REST API in read/write mode can access every configurable element in the database, it is powerful but
must be used with extreme caution: No semantic validation is performed on the data you write to the database,
and configuration errors can destabilize the switch.
On 6300 switches or 6400 switches, by default, the HTTPS server is enabled in read-write mode on the
mgmt VRF. If you enable the HTTPS server on a different VRF, the HTTPS server is enabled in read-only
mode.
Example
Command History
Release Modification
10.07 or earlier --
Command Information
All platforms config Administrators or local user group members with execution
rights for this command.
Description
Enables the firmware site distribution server.
The firmware site distribution allows you to use a switch to distribute a firmware image file to other
switches in the same network. This prevents the switches from connecting to the cloud or an external
network to download a firmware image file.
On enabling the firmware site distribution, it exposes a REST endpoint that allows the switches to
download a switch primary or secondary firmware image.
As per the limitation, up to two switches can download the firmware image simultaneously.
Example
Enabling the firmware site distribution server:
Command History
Release Modification
Command Information
All platforms config Administrators or local user group members with execution
rights for this command.
Description
Invalidates and closes all HTTPS sessions. All existing Web UI and REST sessions are logged out and all
real-time notification feature WebSocket connections are closed.
Usage
Typically, a user that has consumed the allowed concurrent HTTPS sessions and is unable to access the
session cookie to log out manually must wait for the session idle timeout to start another session. This
command is intended as a workaround to waiting for the idle timeout to close an HTTPS session. This
command stops and starts the hpe-restd service, so using this command affects all existing REST
sessions, Web UI sessions, and real-time notification subscriptions.
Example
Command History
10.07 or earlier --
Command Information
All platforms Manager (#) Administrators or local user group members with execution
rights for this command.
https-server session-timeout
https-server session-timeout <MINUTES>
Description
Configures the timeout, in minutes, for any given HTTPS server session. A value of 0 disables the
timeout.
Parameter Description
<MINUTES> Specifies the maximum idle time, in minutes for an HTTPS session.
Default: 20. Maximum: 480 (8 hours). 0 disables the timeout.
Example
Command History
Release Modification
Command Information
All platforms config Administrators or local user group members with execution
rights for this command.
https-server vrf
https-server vrf <VRF-NAME>
no https-server vrf <VRF-NAME>
Description
Configures and starts the HTTPS server on the specified VRF. HTTPS server features include the REST API
and the web user interfaces.
The no form of the command stops any HTTPS servers running on the specified VRF and removes the
HTTPS server configuration.
Usage
By using this command, you enable access to both the Web UI and to the REST API on the specified VRF.
You can enable access on multiple VRFs.
By default, 8320, 8325, 8360, 8400, 9300, and 10000 Switch Series have an HTTPS server enabled on the
mgmt VRF.
By default, the 6200, 6300, and 6400 Switch Series have an HTTPS server enabled on the mgmt VRF and
on the default VRF.
When the HTTPS server is not configured and running, attempts to access the Web UI or REST API result
in 404 Not Found errors.
The VRF you select determines from which network the Web UI and REST API can be accessed.
For example:
n If you want to enable access to the REST API and Web UI through the OOBM port (management IP
address), specify the built-in management VRF (mgmt).
n If you want to enable access to the REST API and Web UI through the data ports (for "inband
management"), specify the built-in default VRF (default).
n If you want to enable access to the REST API and Web UI through only a subset of data ports on the
switch, specify other VRFs you have created.
Aruba Network Analytics Engine scripts run in the default VRF, but you do not have to enable HTTPS
server access on the default VRF for the scripts to run. If the switch has custom Aruba Network Analytics
Engine scripts that require access to the Internet, then for those scripts to perform their functions, you
must configure a DNS name server on the default VRF.
Examples
Enabling access on all ports on the switch, specify the default VRF:
Enabling access on the OOBM port (management interface IP address), specify the management VRF:
Enabling access on ports that are members of the VRF named vrfprogs, specify vrfprogs:
Enabling access on the management port and ports that are members of the VRF named vrfprogs,
enter two commands:
The 6200 switches support only two VRFs. One management VRF and one default VRF. You cannot add another
VRF.
Command History
Release Modification
10.07 or earlier --
Command Information
All platforms config Administrators or local user group members with execution
rights for this command.
show https-server
show https-server [vsx-peer]
Description
Shows the status and configuration of the HTTPS server. The REST API and web user interface are
accessible only on VRFs that have the HTTPS server features configured.
Parameter Description
vsx-peer Shows the output from the VSX peer switch. If the switches do not
have the VSX configuration or the ISL is down, the output from the
VSX peer switch is not displayed. This parameter is available on
switches that support VSX.
Usage
Shows the configuration of the HTTPS server features.
VRF
Shows the VRFs, if any, for which HTTPS server features are configured.
REST Access Mode
Shows the configuration of the REST access mode:
read-write
POST, PUT, and DELETE methods can be called on all configurable elements in the switch database. This is the
default value.
read-only
Write access to most switch resources through the REST API is disabled.
Examples
Session timeout : 20
Command History
Release Modification
10.07 or earlier --
Command Information
All platforms Manager (#) Administrators or local user group members with execution
rights for this command.
The maximum number of concurrent HTTPS sessions per user per switch is six. There is an upper limit of 48 total
sessions per switch. It is a best practice to log out of HTTPS sessions when you are finished using them.
n If you log in to the REST API using the AOS-CX REST API Reference or using the Web UI and open the
API Reference in another browser tab, the browser handles the session cookie for you. You do not
have to save or otherwise manage the session cookie.
n If you access the REST API using another method, such as the curl tool, you must do the following:
o Save the session cookie returned from the login request.
o Pass that saved cookie to the switch with every subsequent request you make to the REST API,
including the logout resource.
Although it is possible to pass the user name and password information as a query string in the
login URL, browser logs or tools outside the switch might save the accessed URL in cleartext in log
entries. Instead, Hewlett Packard Enterprise recommends that you pass the credential information
as data when using programs such as curl to log in to the switch.
For examples of accessing the REST API using curl, see Accessing the REST API using curl.
All users can access the POST method of the login and logout resources. However, the login requests
fail if the user is not a member of one of the predefined user groups. For example, login attempts fail
when attempted by a member of a user-defined local user group.
If a user attempts a request for which they are not authorized, the switch returns an HTTP 403
"Forbidden" error.
If an authorized user attempts a write request but the REST API is in read-only mode, the switch returns
an HTTP 404 "Page not found" error.
Accessing the REST API using the AOS-CX REST API Reference
Although the AOS-CX REST API Reference interacts directly with the REST API, the AOS-CX REST API Reference is not
intended as a management or configuration interface. Use caution when using the Submit button for POST or PUT
methods because this action can result in changes to your current environment.
Prerequisites
n HTTPS server access must be enabled on the VRF from which you are accessing the switch.
n With a few exceptions, using the PUT, POST, or DELETE methods require the following conditions to
be true:
o The REST API access mode must be set to read-write.
o The user name you use to log in must be a member of the administrators group.
Procedure
n To view the reference documentation for the REST v10.04 API, access the following URL using a
browser: https://<IP-ADDR>/api/v10.04/
<IP-ADDR> is the IP address or hostname of your switch.
For example: https://192.0.2.5/api/v10.04/
n To open the reference for the REST v1 API, open a browser at: https://<IP-ADDR>/api/v1/ or at
https://<IP-ADDR>/api/
<IP-ADDR> is the IP address or hostname of your switch.
For example: https://192.0.2.5/api/v1/
Procedure
Log in to the switch using the Login resource.
When you finish your session, log out by expanding the Logout resource and clicking Execute.
n Documents the switch REST API resources, methods, models, and responses.
n Enables you to interact with the switch to view or change the configuration.
At the bottom of the page, the AOS-CX REST API Reference shows base URL and version information. For
example:
n The switch resource URIs are organized in groups. The group names are listed in alphabetical order
on the AOS-CX REST API Reference home page.
The group name does not always match the resource collection name. Use the group names as a
navigation aid only.
n Group names that are in gray have the URI entries—also called endpoints—collapsed. When you
hover over the group name, it turns black. Click the group name to expand it and show the list of
methods and URIs in the group.
You can also use the Show/Hide, List Operations, and Expand Operations controls to expand or
collapse all the members of the group.
n The following example shows the list of the methods and resource URIs in the Subsystem group:
This view is the same view that is shown when you click the List Operations control of the Subsystem
group.
o The methods that are shown might depend on the REST API access mode. Some methods might
not be displayed if the REST API access mode is read-only.
o Methods and resources might be displayed that you do not have the authorization to access. For
example, users with operator rights are not authorized to make PUT or POST requests to most
resources. If you submit a request for which you are not authorized, the switch returns the
following error:
HTTP error 403 "Forbidden"
o The resource collection name is subsystems (not Subsystem).
o Items in braces, such as {id 1}, are path parameters. If you submit a request to a resource URI
that includes a path parameter, you are required to supply a value for the parameter.
n To show more information about an item on the list, click the URI path. The following shows part of
the information displayed when /system/subsystems is selected:
You can use the browser scroll bar to navigate to information about the implementation of this
method and resource, including the required and optional parameters.
o Required parameters are shown in bold.
For example, the POST method of the login resource requires a user name and password:
Although the AOS-CX REST API Reference interacts directly with the REST API, the AOS-CX REST API
Reference is not intended as a management or configuration interface. Use caution when using
the Submit button for POST or PUT methods because this action can result in changes to your
current environment.
n In GET requests, there can be multiple attributes and parameters you can use to filter results. For
example:
, (comma) %2C
: (colon) %3A
When you enter curl commands or submit requests through other means, percent encoding is
permitted but not required in the query string of the URI.
Not all resources support all write methods. See the AOS-CX REST API Reference for the methods
supported by each resource. The REST API must be in read-write mode for the AOS-CX REST API
Reference to show all the write methods a resource supports.
The REST API is powerful but must be used with extreme caution: No semantic validation is performed on the data
you write to the database, and configuration errors can destabilize the switch. Hewlett Packard Enterprise
recommends that you refer to the tested examples when using the REST API to make configuration changes.
LAG interfaces
n LAG interfaces are of type lag.
n You can use the DELETE method to delete a LAG interface.
Example of creating a LAG interface with member ports 1/1/1 and 1/1/2:
Method and URI:
POST "/rest/v1/system/interfaces"
Request body:
{
"name": "lag50",
"vrf": "/rest/v1/system/vrfs/default",
"type": "lag",
"interfaces": [
"/rest/v1/system/interfaces/1%2F1%2F1",
"/rest/v1/system/interfaces/1%2F1%2F2"
]
}
VLAN interfaces
n VLAN interfaces are of type vlan.
n You can use the DELETE method to delete a VLAN interface.
{
"name": "vlan2",
"vlan_tag": "/rest/v1/system/vlans/2",
"vrf": "/rest/v1/system/vrfs/default",
"type": "vlan"
}
n attributes
n count
n depth
n filter
n selector
A path query parameter is specified as a "key=value" pair. When permitted, multiple values are
separated by the comma (,) character.
For example:
n attributes=id,name,type
n count=true
A path query parameter can be used alone or in combination with other parameters. The ampersand (&)
character separates each parameter in the string.
For example:
GET "https://192.0.2.5/rest/v1/system/vlans?depth=1&attributes=id,name,type"
The count and filter attributes and wildcard character are supported from AOS-CX release 10.05 and
later.
Attributes parameter
The attributes parameter of the GET method reduces the returned data for each entry to include only
the attributes specified in the comma-separated list. The attribute names in the URI must match the
attribute names in the AOS-CX REST API Reference.
For a list of the available attributes for a resource, see the GET method of that resource in the AOS-CX
REST API Reference.
Example request:
GET "https://192.0.2.5/rest/v1/system/vlans?depth=1&attributes=id,name,type"
Example response:
{
{
"id": 1,
"name": "DEFAULT_VLAN_1",
"type": "default"
},
{
"id": 2,
"name": "VLAN2",
"type": "static"
},
{
"id": 3,
"name": "VLAN3",
"type": "static"
}
}
Count parameter
The count parameter of the GET method returns the number of entries that match the specified URI.
The count parameter can be useful when specifying resource collections or for getting statistical
information.
You can specify the count parameter as either of the following:
n count
n count=true
Examples:
Depth parameter
The depth parameter of the GET method specifies to what level the URIs in response bodies must be
expanded and replaced by the JSON representation of those resource:
n Default: 0
n Maximum: 3
For each level of depth, the REST API expands one level of URIs into their JSON data representations in
the response body.
Using the depth parameter can result in large amounts of returned data, depending on the number of items in
the list and the amount of JSON data that represents each item.
For example, a GET request on the vlans resource returns a list of URIs. Example request:
GET "https://192.0.2.5/rest/v1/system/vlans"
Example response:
[
"/rest/v1/system/vlans/1",
"/rest/v1/system/vlans/10",
"/rest/v1/system/vlans/20"
]
To specify that those URIs also be expanded and replaced with the JSON data, specify depth=1 as a
parameter in the GET request.
Example request:
GET "https://192.0.2.5/rest/v1/system/vlans?depth=1"
Example response (ellipses represent data omitted from this example):
[
{
"id": 1,
"name": "DEFAULT_VLAN_1",
"type": "default",
…
"flood_enabled_subsystems": [
{
URI-of-first-subsystem
},
…
{
URI-of-last-subsystem
}
]
},
{ "id": 10,
"name": "vlan10",
"type": "static",
…
"flood_enabled_subsystems": [
Each VLAN in the preceding example includes an attribute, flood_enabled_subsystems, which contains
a list of URIs that represent the flood-enabled systems. To specify that those URIs also be expanded and
replaced with the JSON data, specify depth=2 as a parameter in the GET request.
Filter parameter
The filter parameter of the GET method reduces the returned data to include only those entries that
match the filter criteria. Specify the filter criteria in a comma-separated list of attribute name:value
pairs.
Examples:
Selector parameter
The selector parameter of the GET method filters the returned data to include only those attributes
that belong to the specified category. By using the selector parameter, you avoid having to list
attributes individually using the attributes parameter. The default is to include all categories. Use a
comma (,) to separate multiple category values.
The selector categories are the following:
configuration
Contains user-owned information. Attributes in the configuration category can be supplied by users
through REST requests or through the switch CLI. Although an attribute must be in the configuration
category to be modified by a user, not all attributes in the configuration category can be modified
after the resource instance is created.
statistics
Contains system-supplied data such as counters. Attributes in the statistics category cannot be
written by users.
status
Contains system-owned data such as the admin account and various status fields. Attributes in the
status category cannot be written by users.
For example, to get the configuration attributes of all VLANs, when you specify the URI of the GET
method, do the following:
n Specify depth=1 to direct the REST API return the JSON representations of each VLAN instead of the
URI of each VLAN in the list. If you do not specify depth=1, the REST API returns each VLAN
n Not all resources support the POST method. See the AOS-CX REST API Reference for the methods
supported by each resource. The REST API must be in read-write mode to see all the POST methods
supported.
n Some resources support the POST method even when the REST API is in read-only mode.
n When you use the POST method, the URI must point to the collection—not to the resource you are
creating. The resource you are creating is sent in JSON format in the request body.
o The JSON representation must include all fields required by the JSON model of that resource.
o The JSON representation can contain only configuration attributes. It must not contain attributes
in the status or the statistics category.
n You can POST only one resource at a time.
n Not all resources support the PUT method. For information about the methods supported for a
resource, see the AOS-CX REST API Reference. The REST API must be in read-write mode to see all
the PUT methods supported.
n The URI must specify a specific resource, not a collection.
n The URI must specify a resource that currently exists.
n For almost all resources, the PUT method is implemented as a strict replace operation.
All mutable configuration attributes are replaced. Any mutable attribute that the JSON data in request
body does not include is either removed (if there is no default value) or reset to its default value.
PUT behavior
The PUT operation is a replace operation—not an update operation—because the resource instance in
the request body replaces every changeable configuration attribute of the existing resource. PATCH
partial updates are not supported.
Any mutable attribute that the JSON data in request body does not include is either removed (if there is no default
value) or reset to its default value.
For example:
Procedure
1. Use the GET method with selector=writable to obtain the writable (mutable) configuration
attributes for the resource you want to change.
For example:
GET "https://192.0.2.5/rest/v1/system/interfaces/vlan200?selector=writable"
2. Change the values of the attributes to match your wanted configuration.
Any attribute you do not include in the request body will be set to its default value, which could
be empty.
3. Use the resulting JSON data as the request body for the PUT request.
n Not all resources support the DELETE method. See the AOS-CX REST API Reference for the methods
supported by each resource. The REST API must be in read-write mode to see all the DELETE
methods supported.
n The URI must specify a specific resource instance. The URI must not specify a collection.
n Child subcollections and resources are deleted when you delete the parent resource. For example, if
you delete an ACL, its ACL entries are deleted automatically.
n DELETE requests do not contain a request body.
n DELETE requests do not return a response body.
For more information about accounting log entries, see the description of the show accounting log CLI
command.
Protocol
HTTPS
Port
443
Authentication
Session cookie from successful HTTPS login request.
$ curl -k GET \
-b /tmp/auth_cookie \
"https://192.0.2.5/rest"
Prerequisites
n Access to the switch REST API must be enabled.
Procedure
Logging out at the end of the session is important because the number of concurrent HTTPS
sessions per client and per switch are limited, and session cookies are not shared across devices
and scripts.
Credential information (user name, password, domain, and authentication tokens) used in curl commands entered
at a command-line prompt might be saved in the command history. For security reasons, Hewlett Packard
Enterprise recommends that you disable command history before executing commands containing credential
information.
Procedure
Use the following curl command to access the login resource of the switch and provide your user name
and password as data:
Syntax:
curl [--noproxy <IP-ADDR>] -k -X POST
-c <COOKIE-FILE>
-H 'Content-Type: multipart/form-data'
"https://<IP-ADDR>/rest/v1/login"
-F 'username=<USER-NAME>' -F 'password=<PASSWORD>'
Options:
-k
Specifies that the curl program not attempt to verify the server certificate against the list of certificate
authorities included with the curl software.
The switch uses self-signed certificates. By default, the curl program attempts to verify certificates
against its list of certificate authorities, and attempts to verify self-signed certificates fail. Therefore
you must use the –k option to disable attempts to verify self-signed certificates against a certificate
authority.
-X
Although it is possible to pass the user name and password information as a query string in the login URI, system
logs save the accessed URI in cleartext in log entries. Hewlett Packard Enterprise recommends that you pass the
credential information as data instead of in the URI when using programs such as curl to log in to the switch.
Example:
Procedure
Use the following curl command to pass the cookie file back to the switch using the -b option.
Syntax:
curl [--noproxy <IP-ADDR>] -k GET
-b <COOKIE-FILE>
-H 'Content-Type:application/json'
-H 'Accept: application/json'
"https://<IP-ADDR>/rest/v1/system"
Options:
--noproxy <IP-ADDR>
Optional. The --noproxy option is appropriate where execution of curl commands does not need a
proxy to access the applications. If your network is configured to require a proxy to access
applications, use the --proxy option. <IP-ADDR> specifies the IP address or hostname of the switch.
When you use curl, you log in at the beginning of your session and log out at the end of the session. When
you log in, you must save the cookie returned from the login request so that you can pass that same cookie
value to the switch in subsequent curl commands. When you log in, save the cookie file by specifying the -c
option with a file name.
In subsequent curl commands, pass the cookie value back to the switch by specifying the -b option with the
same file name.
-X
Specifies a method that curl would not use by default. Typically, used only with POST, PUT, or DELETE
methods.
Example:
Examples
The following examples show how you can use curl with AOS-CX REST API. The response body might
vary based on the AOS-CX switch series. For example, the 8320 and 6400 switches show VSX
information, whereas the 6300 and 6200 switches show VSF and PoE information.
As a best practice, before you perform a GET, PUT, POST, or DELETE operation, you must login to create
a session and save the cookie file by specifying the -c option with a file name. After you perform the
operation, you must logout to end the session and pass the cookie file back to the switch by specifying
the -b option with the same file name. The following examples assume that you are performing the step
to login before performing the operations in the example and logout after performing the operations.
For more information, see Accessing the REST API using curl.
The request and response body in the following examples contain a truncated part of the actual data. The data
that you see after running the curl commands might vary. Ellipses (…) in the response body represent data not
shown in the example.
It is important to note that the certificate resources do not support the use of internationalized strings. Since
UTF8 is the only supported encoding, a Subject Alternative Name (SAN) must be used instead.
On successful completion, the switch returns response code 200 OK and a response body containing
the certificate resource URLs indexed by the certificate name. For example:
{
"my-cert-1": "/rest/v1/certificates/my-cert-1",
"my-cert-2": "/rest/v1/certificates/my-cert-2"
}
Getting a certificate
Example method and URI:
GET "https://192.0.2.5/rest/v1/certificates/my-cert-2"
Example curl command:
On successful completion, the switch returns response code 200 OK and a response body containing
the certificate.
Deleting a certificate
Example method and URI:
DELETE "https://192.0.2.5/rest/v1/certificates/my-cert-3"
Example curl command:
Procedure
1. Create a TA profile:
a. From the certificate authority (CA), get a copy of the certificate against which you will validate
leaf certificates.
The certificate you validate leaf certificates against can be a root certificate or an
intermediate certificate.
The steps to get the leaf certificate depend on the CA and the operating system you use.
b. Create a JSON object with a certificate key and a name key.
For example:
{
"name": "<profile-name>",
"certificate": "<root-ca-cert>"
}
n For the value of the name key, replace <profile-name> with the name of the TA profile you
want to create.
n For the value of the certificate key, replace <root-ca-cert> by pasting the copied
certificate. After pasting, edit the text to ensure proper loading as a JSON object by doing
the following:
o Ensure the certificate headers and footers are treated as separate lines by adding \n
characters after the header and before the footer.
The following example shows the \n characters in bold.
{
"name": "myta",
"certificate": "-----BEGIN CERTIFICATE-----\nMIIF2DCCA8CgAwIBAgIlCnL
MA0GCSqGSIb3DQEBCwUAMHkxCzAJBgNVBAYTAkdCMRAwDgYDVQQIDAdFbmdsYW5kMRIwEAYDVQD
Al
...
MA0GCSqGSIb3DQEBCwUAMHkxCzAJBgNVBAYTAkdCMRAwDgYDVQQIDAdFbmdsYW5kMRIwEAYD
VQQKDAl
...
PKj0FmJ1+Qzw9Bcm6HiPTyxOVozMeRQzSQhTZVlh3OvBw/cUwTIqFJCe/afNQCqa9XnvTpJv
P/Q3ze6
S4L9sxrk/i3hKB88\n-----END CERTIFICATE-----"
}'
On successful completion, the switch returns response code 200 OK and a response body
containing the CSR in PEM format.
4. Send the CSR to the CA for signing.
The steps to send the CSR depend on the CA and the operating system you use.
The CA returns the signed certificate in PEM format.
5. Import the signed certificate by using a PUT request to update the my-cert-name certificate with
the signed certificate you received from the CA.
The imported certificate data must include all the intermediate CA certificates in the certificate chain
leading to the certificate that was imported into the specified TA profile.
If you copy and paste the certificate into a JSON object, you must ensure that the certificate and private
key headers and footers are processed as separate lines by editing the text to add \n characters as
needed.
As part of the PUT request, the switch attempts to validate the certificate against the pool of all TA
profiles installed on the switch. The certificate is accepted if it is validated with one of the TA profiles.
On successful completion, the switch returns response code 200 and a JSON object containing the
configuration attributes.
2. In the portion of the response body that defines the certificate name for the HTTPS server,
change the value to: my-cert-name.
The certificate name associated with the HTTPS server is the value assigned to the https-server key,
which is under the certificate_association key. By default, the certificate name is: local-cert.
The request body of a PUT request is permitted to include only the mutable configuration attributes. In
the AOS-CX software releases to which this example applies, all the configuration attributes for the
system resource are mutable attributes, so you do not need to edit the JSON object to remove the
immutable attributes.
3. Using a PUT request, update the system resource with the edited JSON data as the request body.
Example method and URI:
PUT "https://192.0.2.5/rest/v1/system"
Example request body:
{
"aaa": {
...
},
...
"certificate_association": {
"https-server": "my-cert-name",
"syslog-client": "local-cert"
},
...
}
On successful completion, the switch returns response code 200 OK and a response body containing
the entire configuration in JSON format.
Uploading a configuration
The following example shows uploading a configuration to become the running configuration. The
running configuration is the only configuration that can be updated using this technique, however, you
can copy other configurations. For more information about copying configurations, see Copying a
configuration.
The configuration being uploaded—represented as ellipsis but not shown in this example—is in JSON
format in the body of the command (enclosed in braces).
Copying a configuration
To replace an existing configuration with another, use a REST PUT request to the destination
configuration. Use the from query string parameter to specify the source configuration.
In the curl command, the POST request is handled as part of the -F option.
On successful completion, the switch returns response code 200 OK and a response body containing
the output string produced by the ping operation.
On successful completion, the switch returns response code 200 OK and a response body containing
the output string produced by the traceroute operation.
Changing a password
Example method and URI:
PUT "https://192.0.2.5/rest/v1/system/users/myadmin"
Example request body:
{
"password": "P@ssw0rd2g"
}
Example curl command:
Deleting a user
Example method and URI:
DELETE "https://192.0.2.5/rest/v1/system/users/myadmin"
Example curl command:
3. Getting the ACL configuration information to use in the next step. Ellipses (…) represent data not
shown in the example.
4. Updating the ACL configuration using the return body received from the GET request performed
in the previous step.
When you send a PUT request, the JSON request body must not contain immutable attributes. The
AOS-CX REST API Reference model for the PUT method of the resource shows the mutable attributes.
Any mutable attributes you do not include in the PUT request body are set to their defaults, which
could be empty.
"https://192.0.2.5/rest/v1/system/interfaces/1%2F1%2F2?selector=configuratio
n"
{
...
"options": {},
"other_config": {},
"udld_arubaos_compatibility_mode": "forward_then_verify",
"udld_compatibility": "aruba_os",
"udld_enable": false,
"udld_interval": 7000,
"udld_retries": 4,
"udld_rfc5171_compatibility_mode": "normal",
"user_config": {}
...
}
7. Verifying which configuration attributes are mutable and therefore can be included in the PUT
request.
When you send a PUT request, the JSON request body must not contain immutable attributes.
The AOS-CX REST API Reference JSON model for the PUT method of the resource shows the
mutable attributes. Any mutable attributes you do not include in the PUT request body are set to
their defaults, which could be empty.
In the preceding example, the following mutable attribute listed in the previous step was not
included, so it is set to its default, which could be empty:
selftest_disable
10. Adding the ACL information to the port using the return body received from the GET request
performed in the previous step after verifying the values that are permitted in the JSON model for
the PUT method. The modified values are shown in the following example.
Ellipses (…) represent data not shown in the example.
The following uses of /vsx-peer in the URI path are not supported:
n You cannot specify the login resource. Requests to /vsx-peer/rest/v1/login are not required because
logging in to one device automatically gives you access to the peer device.
n You cannot access the Web UI of a VSX peer switch. Setting the browser address to https://<connected_
switch_ip>/vsx-peer is not supported.
n You cannot specify a VSX peer switch in the URIs in topic subscription messages in the real-time notifications
framework. However, you can access the real-time notifications framework on the VSX peer switch by setting
the connection address to the following:
wss://<connected_switch_ip>/vsx-peer/rest/v1/notification
Please note the following points when using REST API with VSX.
n VSX must be enabled on both switches, and the interswitch link (ISL) must be up.
n REST API access must be enabled on the switch to which you are connected.
n For write access, the REST API access mode must be set to read-write on the switch to which you are
connected.
n You must be logged in to the switch to which you are connected. For example, if you are connected to
the primary VSX switch, you must be logged in to the primary switch.
n When configuration synchronization is enabled, supported configuration changes on the primary VSX
switch are replicated on the secondary VSX switch. Changing the configuration of a secondary VSX
switch might cause the configurations to be out of synchronization.
n Audit messages are logged on the peer switch, with the user information from the switch to which the
user is connected.
Getting the names and IP addresses of interfaces on secondary VSX switch while connected to the
primary VSX switch at IP address 192.0.2.5:
For more information about VSX, see the Virtual Switching Extension (VSX) Guide.
Getting the VSX status of the secondary VSX switch while connected to the primary VSX switch at IP
address 192.0.2.5:
You can also get the VSX status of the primary VSX switch while connected to the secondary VSX switch.
Prerequisites
n The admin password must be configured on the VSX peers.
In the following examples, Virtual Switching Extension (VSX) is enabled, the primary VSX switch IP
address is 10.102.8.145, the software update URL is tftp://10.100.0.12/halon/GL_10_07_0001BC.swi,
and the VRF is mgmt.
To log in to VSX primary, use the following command:
For more information, see the Virtual Switching Extension (VSX) Guide.
Connection protocol
WebSocket secure (wss://)
Port
443
Message format
JSON
Message types
The following are the supported message types:
n subscribe
n unsubscribe
n success
n error
n notification
Authorization
Session cookie from successful HTTPS login request
Subscription persistence
Configuration maximums
n Maximum number of subscribers per switch: 50
n Maximum number of subscriptions per subscriber: 80
n Maximum number of topics in one subscription message: eight
Procedure
Enable REST API access on the VRF from which you will access the switch.
Procedure
1. Open a web browser page and log in to the switch Web UI or the REST API.
The session cookie is managed by the browser and is shared among browser tabs.
2. From a different tab in the same browser, open the page that contains the WebSocket interface.
For example, many browsers have a plugin for secure WebSocket connections.
3. Connect to the switch at the following URL:
wss://<IP-ADDR>/rest/v1/notification
<IP-ADDR> is the IP address of the switch.
For example:
wss://192.0.2.5/rest/v1/notification
After the connection is established, you can use the interface to send subscribe or unsubscribe
messages and to view the responses and notification messages.
Subscribing to topics
Prerequisites
n You must have a secure WebSocket connection to the switch.
n Access to the switch REST API must be enabled. The REST API access mode can be either read-only or
read/write.
Procedure
Using the WebSocket secure connection, send a subscribe message that contains the topics to which
you want to subscribe and a poll interval hint, if any.
Some resource attributes—typically in the statistics category—are not populated until a client requests
the information. The value of hint specifies how often—in seconds—the notification subsystem is to
request information about the topics in the list.
For example:
{
"type": "subscribe",
"topics": [
{
"name": "/rest/v1/system/vrfs"
},
{
"name": "/rest/v1/system/vlans/1?attributes=admin,oper_state_reason"
}
],
"hint": 5
}
If the subscriber already has a subscription to the specified topic, the following error is returned:
{
"type":"error",
"message":"The topic or combination of topics have been already subscribed."
}
If the URI in the topic name specifies a resource that is not in the configuration and state database, the
following error is returned:
{"type":"error","message":"Object not found."}
Example of a message returned by a successful subscription attempt:
{
"type": "success",
"subscriber_name": "4bcf8uka90ki",
"subscription_name": "ns83n58dky",
"data": [
Procedure
Use the secure WebSocket connection to send an unsubscribe message that specifies the topic or topics
from which you no longer want notifications.
Use a comma to separate topics in a list of topics.
You must be connected as the same subscriber that subscribed to the topic. For example, you must be
using the same web browser session or be passing the same session cookie with the request.
For example, to unsubscribe notifications about the default VRF, send the following message through
the WebSocket secure connection:
{
"type": "unsubscribe",
"topics": [
{
"name": "/rest/v1/system/vrfs/default"
}
]
}
If the subscriber does not have a subscription to that topic, the following message is returned:
Components of a topic
In a subscription success message, each topic in the data contains the following components:
topicname
Contains the name of the topic, identified by the URI of the switch resource, including the optional
query string.
resources
Contains a comma-separated list of one or more resources in JSON format. When the URI of a topic
is a resource collection, a topic includes multiple resources. In the example message, the vrfs
resource includes two VRF instances: default and mgmt.
Each resource includes the following components:
operation
Components of a topic
In a notification message, each topic in the data contains the following components:
topicname
Contains the name of the topic, identified by the URI of the switch resource, including the optional
query string.
resources
Contains a comma-separated list of one or more resources in JSON format. When the URI of a topic
is a resource collection, a topic includes multiple resources.
Each resource includes the following components:
operation
For notification messages, operation is one of the following values:
inserted
The resource or resource attribute was added to the configuration of the switch.
deleted
The resource or resource attribute was deleted from the switch.
modified
The resource or resource attribute changed.
uri
Contains the URI of the resource instance within the resource collection. If the topicname is a
resource instance instead of a collection, uri matches the path portion of the URI in topicname.
values
The content of values depends on the operation:
n Access to the switch REST API must be enabled on the VRF through which this browser will connect to
the switch.
n Before you can use the HTML page, you must log in to the switch Web UI or REST API from a separate
tab in the same web browser session. The browser shares the session cookie between tabs.
n When the browser page is open, in Server Location, substitute the switch IP address for
{IPAddress} in wss://{IPAddress}/rest/v1/notification, then click Connect.
n Enter the subscription message in Request and click Send.
n Responses and notifications are shown in Response.
Example screen
<!DOCTYPE html>
<html lang="en">
<head>
<title>Web Socket Client Example</title>
<script type="text/javascript">
window.onload = function () {
var conn;
function appendLog(item) {
var doScroll = log.scrollTop === log.scrollHeight -
log.clientHeight;
log.appendChild(item);
if (doScroll) {
log.scrollTop = log.scrollHeight - log.clientHeight;
}
}
document.getElementById("connect").onclick = function () {
var server = document.getElementById("wsURL");
conn = new WebSocket(server.value);
if (window["WebSocket"]) {
if (conn) {
conn.onopen = function (evt) {
document.getElementById("disconnect").disabled = false
document.getElementById("sendMsg").disabled = false
document.getElementById("connect").disabled = true
document.getElementById("status").innerHTML =
"Connection opened"
}
conn.onclose = function (evt) {
document.getElementById("status").innerHTML =
"Connection closed"
document.getElementById("connect").disabled = false
};
conn.onmessage = function (evt) {
var messages = evt.data.split('\n');
for (var i = 0; i < messages.length; i++) {
var item = document.createElement("pre");
item.innerText = messages[i];
appendLog(item);
}
}
}
} else {
var item = document.createElement("pre");
item.innerHTML = "<b>Your browser does not support
WebSockets.</b>";
appendLog(item);
}
};
document.getElementById("disconnect").onclick = function () {
conn.close()
document.getElementById("sendMsg").disabled = true
document.getElementById("connect").disabled = false
document.getElementById("disconnect").disabled = true
document.getElementById("status").innerHTML = "Connection closed"
};
document.getElementById("form").onsubmit = function () {
if (!conn) {
return false;
}
if (!msg.value) {
return false;
}
conn.send(msg.value);
</script>
<style type="text/css">
html {
overflow: hidden;
}
body {
overflow: hidden;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: gray;
}
#log {
background: white;
margin: 0;
padding: 0.5em 0.5em 0.5em 0.5em;
top: 1.5em;
left: 0.5em;
right: 0.5em;
bottom: 3em;
overflow: auto;
position: absolute;
height: 530px;
}
#form {
padding: 0 0.5em 0 0.5em;
margin: 0;
position: absolute;
bottom: 3em;
top: 5em;
left: 8px;
width: 100%;
overflow: hidden;
}
#serverLocation {
padding-top: 0.3em;
}
#requestSection {
height: 38px;
}
#responseMsgSection {
height: 570px;
position: relative;
}
</style>
</head>
<body>
Prerequisites
You must be logged in to the switch REST API.
Procedure
n To get the list of current subscribers, send a GET request to the notification_subscribers
resource.
For example:
GET "https://192.0.2.5/rest/v1/system/notification_subscribers"
The response body is a list of URIs. The identifier at the end of the URI string is the subscriber name.
For example:
[
"rest/v1/system/notification_subscribers/z6901beisjgf",
"rest/v1/system/notification_subscribers/18l9g87erb42"
]
Ton get a list of all subscriptions of all subscribers, use the depth=1 parameter when sending the GET
request to the notification_subscribers resource.
For example:
[
{
"name": "z6901beisjgf",
"notification_subscriptions": {
"5mzo50lgoo": "rest/v1/system/notification_
subscribers/z6901beisjgf/notification_subscriptions/5mzo50lgoo",
"pouswxt9m9": "rest/v1/system/notification_
subscribers/z6901beisjgf/notification_subscriptions/pouswxt9m9"
},
"type": "ws"
},
{
"name": "18l9g87erb42",
"notification_subscriptions": {
"dz95lljqwk": "rest/v1/system/notification_
subscribers/18l9g87erb42/notification_subscriptions/dz95lljqwk"
},
"type": "ws"
}
]
Ton get a list of subscriptions that belong to a specific subscriber, send a GET request to the
notification_subscriptions resource of the subscriber.
The following example gets the list of all the subscriptions of subscriber z6901beisjgf:
GET "https://192.0.2.5/rest/v1/system/notification_
subscribers/z6901beisjgf/notification_subscriptions"
The response body is a list of URIs. The identifier at the end of the URI string is the subscription name.
Example response body:
[
"rest/v1/system/notification_subscribers/z6901beisjgf/notification_
subscriptions/5mzo50lgoo",
"rest/v1/system/notification_subscribers/z6901beisjgf/notification_
subscriptions/pouswxt9m9"
]
n To get detailed information about a specific subscription, send a GET request to the notification_
subscriptions/{subscription-ID} resource for that subscription.
The notification_subscriptions resource is a child resource of the specific subscriber:
/system/notification_subscribers/{subscriber-id}/notification_subscriptions/
{subscription-id}
For example, to get information about subscription 5mzo50lgoo, you must specify the subscriber name
and the subscription name in the URI:
{
"5mzo50lgoo": {
"resource": [
"/rest/v1/system/ports?attributes=admin,vlan_mode,vlan_tag,vlan_
trunks,interfaces&depth=1"
]
}
}
n To get detailed information about all subscriptions of specific subscriber, use the depth=1 parameter
when sending the GET request to the notification_subscriptions resource of that subscriber.
For example:
GET "https://192.0.2.5/rest/v1/system/notification_
subscribers/z6901beisjgf/notification_subscriptions?depth=1"
Example response body:
{
"5mzo50lgoo": {
"resource": [
"/rest/v1/system/ports?attributes=admin,vlan_mode,vlan_tag,vlan_
trunks,interfaces&depth=1"
]
},
"pouswxt9m9": {
"resource": [
"/rest/v1/system/interfaces?attributes=type,hw_intf_info,link_state,link_
speed,error,other_config"
]
}
}
Troubleshooting
n To connect to the REST API through the management (OOBM) port, REST API access must be enabled
on the management VRF.
n To connect to the REST API through a data port, REST API access must be enabled on the default VRF
or a user-created VRF that includes that data port.
[
"/rest/v1/system/subsystems/chassis,base",
"/rest/v1/system/subsystems/line_card,1%2F3",
"/rest/v1/system/subsystems/management_module,1%2F5"
]
o Example request:
GET "https://192.0.2.5/rest/v1/system/subsystems/chassis,base?attributes=product_
info"
Example response body:
{
"product_info": {
"base_mac_address": "00:00:5E:00:53:00",
"device_version": "",
"instance": "1",
"number_of_macs": "512",
"part_number": "JL375A",
"product_description": "8400 8-slot Chassis/3xFan Trays/18xFans/Cable
Manager/X462 Bundle",
"product_name": "8400 Base Chassis/3xFT/18xFans/Cbl Mgr/X462 Bundle",
"serial_number": "SG00A2A00A",
"vendor": "Aruba"
}
}
[
"/rest/v1/system/subsystems/chassis/base",
"/rest/v1/system/subsystems/line_card,1%2F1",
"/rest/v1/system/subsystems/management_module,1%2F1"
]
Troubleshooting | 91
The following is an example of a response body for an Aruba 8320 switch:
{
"platform_name": "8320"
}
{
"platform_name": "8400X"
}
n The words "port" and "interface" have meanings that are different from other network operating
systems. In the AOS-CX operating system:
o A port is the logical representation of a port.
o An interface is the hardware representation of a port.
n You can enable debugging logs by using the debug command. The module name is rest. You can
specify all severity log levels or a minimum severity log level.
Example specifying all severity log levels:
Category Description
2xx Indicates that the request was accepted successfully.
4xx Returns the client-side error response with the error message.
5xx Returns the server-side error response with the error message.
The following are some response codes that you will see in the REST API.
Response
Status Description
code
200 OK Returned from GET and PUT operations, and non-configuration API calls
such as Login or Logout when the request is successfully completed.
201 Created Returned from POST operations when a new resource was successfully
created.
204 No Content Returned from a PUT, POST, or DELETE operation when the request was
successfully processed and there is no content to return.
400 Bad request A problem with the request body, such as invalid syntax, incorrectly
formatted JSON, or data violating a database constraint.
401 Unauthorized No active session for this client (the login API has not been called) or too
many sessions already created from this client.
403 Forbidden The client session is valid, but does not have permissions to access the
requested resource.
404 Not found The resource does not exist, or the URI is incorrect for the desired resource.
Can also occur when accessing the POST, PUT, or DELETE API while the REST
access-mode is set to read-only.
500 Internal server An unexpected error has occurred in processing the request. View the logs
error on the device for details.
503 Service The device is receiving more requests than it can process and is defensively
unavailable rejecting requests to protect resources.
Cause
The switch is shipped from the factory with a default user named admin without a password. The admin
user must set a valid password before HTTPS servers can be enabled.
Action
From the global configuration context, set a valid password for the admin user.
For example:
Troubleshooting | 93
Cause
The curl program could not verify the switch server certificate against the CA certificate bundle that
comes with the curl installation, and you did not include the -k option in the curl command.
Action
Retry the command with the -k option included.
The switch HTTPS server uses self-signed certificates, which cannot be verified against a certificate
authority. The -k option disables curl certificate validation.
For example:
Cause
The method used for this REST request is not supported for the specified resource. For example, the
Invalid operation response is returned if you attempt a DELETE request on the system resource.
Action
Use a method supported by the resource.
The AOS-CX REST API Reference displays the methods supported by each resource.
Cause
The JSON data in the POST or PUT request body contains non-configuration or immutable attributes.
Action
Retry the request with the correct JSON resource model for that PUT or POST method.
To determine the configuration attributes of a resource, you can send a GET request with the
selector=configuration query parameter to the resource. Using the REST v10.04 API, you can also use
the GET method with the selector=writable parameter to get only the mutable configuration
attributes of the resource.
You can also use the AOS-CX REST API Reference to verify the JSON model of the PUT or POST method of
the resource.
Cause
You attempted to delete a resource that is referenced by other resources. Typically, this error occurs for
resources that have no clear parent in the resource hierarchy, such as ports. For example, the
Reference failure response is returned if you attempt a DELETE request on a port.
Action
Remove all references to the resource.
After all references to a resource are removed, the resource is deleted automatically.
Solution 1
Cause
The user attempting the request is not logged into the REST API for one of the following reasons:
Action
Log in to the REST API.
Solution 2
Cause
The user attempting the request is not logged in to the REST API because the user did not pass the
correct session cookie to the API. Typically, incorrect session cookies are not a cause when accessing the
REST API through a browser because the browser automatically handles the session cookie.
Action
Troubleshooting | 95
1. Ensure that you save the session cookie returned from the login request.
2. Ensure that you pass the same cookie back to the switch with every REST API request, including
the request to log out.
Cause
A user attempted to log into the REST API or the Web UI, but that user already has the maximum
number of concurrent sessions running.
Action
1. Log out from one of the existing sessions.
Browsers share a single session cookie across multiple tabs or even windows. However, scripts
that POST to the login resource and later do not POST to the logout resource can easily create the
maximum number of concurrent sessions.
2. If the session cookie is lost and it is not possible to log out of the session, then wait for the
session idle time limit to expire.
When the session idle timeout expires, the session is terminated automatically.
3. If it is required to stop all HTTPS sessions on the switch instead of waiting for the session idle time
limit to expire, you can stop all HTTPS sessions using the https-server session close all
command.
This command stops and starts the hpe-restd service, so using this command affects all existing
REST sessions and Web UI sessions.
Cause
The user attempting the request is not a member of the administrators group.
Action
Log in to the REST API with a user name that has administrator rights as part of the administrators
group.
The user must be a member of the predefined administrators group. POST requests to the login
resource fail for members of a user-defined local user group.
Cause
The user attempting the request is a member of the Auditors group, and the GET request specified a
switch resource that users with auditor rights are not permitted to access.
Action
Log in to the REST API with a user name that has operator or administrator rights.
HTTP 404 error "Page not found" when accessing the switch
URL
Symptom
The switch is operational and you are using the correct URL for the switch, but attempts to access the
REST API or Web UI result in an HTTP 404 "Page not found" error.
Cause
REST API access is not enabled on the VRF that corresponds to the access port you are using. For
example, you are attempting to access the REST API or Web UI from the management (OOBM) port, and
access is not enabled on the mgmt VRF.
Action
Use the https-server vrf command to enable REST API access on the specified VRF.
For example:
Cause
The resource does not exist in the system. The URI in the request is incorrect.
The bridge collection was eliminated from the REST v1 API in AOS-CX version 10.03.
Troubleshooting | 97
Action
Remove the following from the URI and retry the request:
bridge/
Example of getting the list of VLANs for a switch running AOS-CX version 10.02:
GET "https://192.0.2.5/rest/v1/system/bridge/vlans"
Example of getting the list of VLANs for a switch running AOS-CX version 10.03:
GET "https://192.0.2.5/rest/v1/system/vlans"
Cause
The resource does not exist in the system. The URI in the request is incorrect for the version of the REST
API specified in the request.
Action
Verify the URI of the resource and retry the request.
The schema for resources accessed through the REST v1 API can differ from the schema for the
resources accessed through the REST v10.04 API.
For example, a REST request with the following URI will fail because the interfaces collection does not
exist in the REST v1 API:
/rest/v1/system/interfaces/lag50
The correct URI for the lag50 resource in the REST v1 API is the following:
/rest/v1/system/ports/lag50
Cause
The resource does not exist in the system. The URI in the request is incorrect or the resource has not
been added to the configuration.
Action
Verify the URI of the resource you are attempting to change or delete and retry the request.
Cause
The REST API access mode is set to read-only.
Action
Set the REST API access mode to read-write.
Enabling the read-write mode on the REST API allows POST, PUT, and DELETE operations to be called on
all configurable elements in the switch database.
Logout fails
Symptom
An attempt to log out of the REST API from a script or curl command fails.
Cause
The session cookie was not supplied or does not contain the correct session token.
Action
1. Repeat the command and send the correct session cookie or modify the script to send the correct
session cookie.
2. If the session cookie has been lost and it is not possible to log out of the session, wait for the
session idle time limit to expire.
When the session idle timeout expires, the session is terminated automatically.
Troubleshooting | 99
Chapter 10
Support and Other Resources
AOS-CX 10.10 REST v1 API Guide | (All AOS-CX Series Switches) 100
channel on
YouTube.
Software https://licensemanagement.hpe.com/
licensing and
Feature Packs
End-of-Life https://www.arubanetworks.com/support-services/end-of-life/
information
Accessing Updates
You can access updates from the Aruba Support Portal or the HPE My Networking Website.
My Networking
https://www.hpe.com/networking/support
To view and update your entitlements, and to link your contracts and warranties with your profile, go to
the Hewlett Packard Enterprise Support Center More Information on Access to Support Materials
page:
https://support.hpe.com/portal/site/hpsc/aae/home/
Access to some updates might require product entitlement when accessed through the Hewlett Packard
Enterprise Support Center. You must have an HP Passport set up with relevant entitlements.
Some software products provide a mechanism for accessing software updates through the product
interface. Review your product documentation to identify the recommended software update method.
To subscribe to eNewsletters and alerts:
https://asp.arubanetworks.com/notifications/subscriptions (requires an active Aruba Support Portal
(ASP) account to manage subscriptions). Security notices are viewable without an ASP account.
Warranty Information
To view warranty information for your product, go to https://www.arubanetworks.com/support-
services/product-warranties/.
Documentation Feedback
Aruba is committed to providing documentation that meets your needs. To help us improve the
documentation, send any errors, suggestions, or comments to Documentation Feedback (docsfeedback-
[email protected]). When submitting your feedback, include the document title, part number, edition,
and publication date located on the front cover of the document. For online help content, include the
product name, product version, help edition, and publication date located on the legal notices page.
AOS-CX 10.10 REST v1 API Guide | (All AOS-CX Series Switches) 102