Using API in ArubaOS Switches with Postman by Ulises Cázares

 Hi, today I'm gonna show how to interact with the Aruba OS version 16.10 switches API using postman.

My intention is that you know how to construct the request using headers, parameters and the body of the request.

The first things to start working with the switch API are: to have administrative access to the device and to make sure of the switch version so you can look for the appropiate document. Remember, APIs can change form version to version. 

You can use the command: show version. In my case is 16.10

Then you can make a quick search in google like "Aruba switch 16.10 API" to get the document and find out what are the option provided in the API. In the document you will find examples using curl and that's why i'm writting this in postman, so you have options.


Now, let's do 4 thing so you can use the API:

  1. Make sure the REST interface is enable or enable it
  2. Login to the device API
  3. Construct a GET request
  4. Construct a POST request


  1.  Make sure the REST interface is enable or enable it   
  2. Login to the device (using administrative credentials). 
    1. According to the documentation, the URL is:  http://Switch-IP/rest/v1/login-sessions 
    2. In Postman, construct it like this:
      1.  It's a http POST to the URL
      2. In the body use "userName" and "password" variables with your adminsitrative credentials. Note.- The variables are case sensitive
    3. If everything is ok you will get a response like this:
      1. This respone includes the cookie with the sessionid so you can make requests. Copy the cookie value becasue you'll use it in the next sections.
         
  3. Construct a GET request
    1.  According to the documentation, to obtaint he vlans the URL is:  http://Switch-IP/rest/v1/vlans
      1. It's a GET to the URL
      2. This time we use a Header to include the Cookie and the value obtained from the previous step
      3. We don't need anything in the body if we want all the vlans.
      4. If everything is ok, you'll get something like this:
         
  4. Construct a POST request
    1. According to the documentation, to create vlans the URL is:  http://Switch-IP/rest/v1/vlans
    2. It's a POST to the URL
    3. This time we use a Header to include the Cookie and the value obtained from the previous step
    4. Since we're creating something we need more information in the request. In this case, the number and the name of the vlan in the body of the request
    5. If everythig is ok you'll get something like this:  

When you get an error after a GET or a POST review the code of the status, it'll give you a clue or reason of why the method didn't work.


In order to do more things with the switch API, refer to the documentation. 



Hope this helps


 

 

 

 

 

Comments

  1. Great job Ulises! You can search HPE resources such as REST API on https://support.hpe.com/connect/

    ReplyDelete

Post a Comment

Popular posts from this blog

Aruba Clearpass - How to configure the Cisco WLC for Guest and MAC Caching by Ulises Cázares

WiFi - How to know supported channels by a wireless client by Ulises Cázares