Using API in Aruba Controllers or Mobility Conductor with Postman by Ulises Cázares
Hi, today I'm gonna show how to interact with the Aruba OS Controlleros or Mobility Conductor 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 MC/MM API are: to have administrative access to the device and to make sure of the MC/MM 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 8.6.0.x
Then you can make a quick search in google like "Aruba OS 8.6. 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.
Another way to see the available methods and options within the MM/MC API is that after you login to the controller or MM you type API as the URI like this. https://MCorMM-IP:4343/api
Now, let's do 2 thing so you can use the API:
- Login to the device API
- Construct a GET request
- Construct a POST request
- Login to the device (using administrative credentials).
- According to the documentation, the URL is: https://MCorMM-IP:4343/v1/api/login. Where "MCorMM-IP" is the IP of MM (Mobility Conductor based) or MC (standalone controller based)
- Take note that the port is 4343 and not 443.
- In Postman, construct it like this:
- It's a https GET to the URL
- In the params (parameters) section use "username" and "password" variables with your administrative credentials. Note.- The variables are case sensitive
- If everything is ok you will get a response like this:
- This respone includes the UIDARUBA variable with the sessionid so you can make requests. Copy the UIDARUBA value becasue you'll use it in the next sections.
- Construct a GET request
- According to the documentation, to obtaint the system information the URL is: https://MCorMM-IP:4343/v1/configuration/object/sys_info
- It's a GET to the URL
- This time we use a param to include the UIDARUBA value and another param for the path to which the command is applied. The config_path is something used in Version 8 of Aruba architecture due to the hierarchy configuration.
- If everything is ok, you'll get something like this:
- Construct a POST request
- According to the documentation, to create a guest account the URL is: https://MCorMM-IP:4343/v1/configuration/object
- It's a POST to the URL
- This time we use a param to include the UIDARUBA value and another param for the path to which the command is applied. The config_path is something used in Version 8 of Aruba architecture due to the hierarchy configuration.
- Since we're creating something we need more information in the request. In this case, we need at least the following object info filled to create the guest user: "action" set to add, "user-role", "name", "password" and "user-email".
- If everything is ok, we'll get something like this: As we can see the response contains everything we sent but adds the result part including the status and that's how we know if it worked or not.
- The request will not commit the changes until we sent another request to the URL: https://MCorMM-IP:4343/v1/configuration/object/write_memory with the UIDARUBA and the config-path variables.
In the Aruba documentation, when using curl, it refers the body section we're using in postman, as the payload-file, but you can use it as shown here with no problem.
The tricky part working with the controller/MM API is that we have to get the structure of the objects or containers, to construct a request, from a GET request or find complete examples as I did.
And remember, if an object needs another to be created first, we have to do it in advance. For example: If we want to create an interface_vlan we need to create the VLAN first
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.
Comments
Post a Comment