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:
- Make sure the REST interface is enable or enable it
- Login to the device API
- Construct a GET request
- Construct a POST request
- Make sure the REST interface is enable or enable it
- Login to the device (using administrative credentials).
- According to the documentation, the URL is: http://Switch-IP/rest/v1/login-sessions
- In Postman, construct it like this:
- It's a http POST to the URL
- In the body use "userName" and "password" variables with your adminsitrative credentials. Note.- The variables are case sensitive
- If everything is ok you will get a response like this:
- 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.
- Construct a GET request
- According to the documentation, to obtaint he vlans the URL is: http://Switch-IP/rest/v1/vlans
- It's a GET to the URL
- This time we use a Header to include the Cookie and the value obtained from the previous step
- We don't need anything in the body if we want all the vlans.
- If everything is ok, you'll get something like this:
- Construct a POST request
- According to the documentation, to create vlans the URL is: http://Switch-IP/rest/v1/vlans
- It's a POST to the URL
- This time we use a Header to include the Cookie and the value obtained from the previous step
- 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
- 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
Great job Ulises! You can search HPE resources such as REST API on https://support.hpe.com/connect/
ReplyDeleteThanks Fer
Delete