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:

  1. Login to the device API
  2. Construct a GET request
  3. Construct a POST request
  1. Login to the device (using administrative credentials). 
    1. 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)
      1. Take note that the port is 4343 and not 443.
         
    2. In Postman, construct it like this:
      1.  It's a https GET to the URL
      2. In the params (parameters) section use "username" and "password" variables with your administrative credentials. Note.- The variables are case sensitive
    3. If everything is ok you will get a response like this:
      1. 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.
  2. Construct a GET request
    1.  According to the documentation, to obtaint the system information the URL is:  https://MCorMM-IP:4343/v1/configuration/object/sys_info 
      1. It's a GET to the URL
      2. 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.
      3. If everything is ok, you'll get something like this: 
  3. Construct a POST request
    1. According to the documentation, to create a guest account the URL is:  https://MCorMM-IP:4343/v1/configuration/object
    2. It's a POST to the URL
    3. 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.
    4. 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". 
    5. 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.
    6. 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. 



Hope this helps

Comments

Popular posts from this blog

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

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

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