ArubaOS-S REST API – VLAN Example

Example – VLAN commands

In this example, we will create a session, use the session cookie to retrieve VLAN information, then create a VLAN, update that VLAN and delete it again.


The switch create a session cookie for every authentcated user. We then use the session cookie in the header of following requests to authenticate us.
I create the requests in Postman.

The body of the request contains the actual data we want the switch to use, the URI tells the switch how to use it and the POST tells it wether to create the session or to delete it.


We get the HTTP result “201 Created” with the session cookie we can use for our requests:

GET VLAN information

We don’t need to send the username and password in thte body anymore, so we can delete it. We now identify using the cookie in the request header.

Added header “SessionId” with our cookie

As a result we get HTTP “200 OK” and VLAN information in JSON format:


To create a new VLAN, we use the same URI, but we use post instead of get. We also need to add data to the body, with which the switch creates the VLAN.
What data needs to be sent can be taken from the API documentation.
The header keeps the SessionId cookie from before.

Here I will create VLAN 15, which has jumbo frames enabled:

"vlan_id": 15,
"name": "API-VLAN-15",
"is_jumbo_enabled": true,
"is_voice_enabled": false,
"is_dsnoop_enabled": false,
"is_dhcp_server_enabled": false,
"is_management_vlan": false

Note that the VLAN id needs to be new on the switch. For existend VLANs we need to use put (see below).


Result: “201 Created” and the information about the VLAN we just created

Switch_2540(config)# sh vlan 15

 Status and Counters - VLAN Information - VLAN 15

  VLAN ID : 15
  Name : API-VLAN-15
  Status : Port-based
  Voice : No
  Jumbo : Yes

  Port Information Mode     Unknown VLAN Status
  ---------------- -------- ------------ ----------

Update / Change VLAN

Existent VLANs need to be changed using PUT instead of POST.
The URI also changes to the URI of that specific VLAN. The data stays in the same format.


Result: “200 OK”

Switch_2540(config)# sh vlan 15

 Status and Counters - VLAN Information - VLAN 15

  VLAN ID : 15
  Name : Changed-VLAN-15
  Status : Port-based
  Voice : No
  Jumbo : Yes

Delete VLAN

We delete the VLAN by calling DELETE on the VLAN specific URI. We just need the cookie in the header, no body is needed.


Result: “204 No Content”

Switch_2540(config)# sh vlan 15
VLAN 15 not found.


The logout is as easy as the login, just use DELETE, no data is needed.

Result: “204 No Content”

Leave a Reply

Your email address will not be published. Required fields are marked *