Cisco ACI Programmability – Using REST APIs

To start we’re going to use the POSTMAN REST client. It can be downloaded for free from the Chrome Web Store. You can use any other REST client if you prefer one from Mozilla, for example.  Within Postman we make GET, PUT, POST, and DELETE calls to the API (there are other calls, but these are the four used most). We then use XML or JSON code in the payload which is where the programmability occurs. In the picture below we see the saved collections on the left. We can see that I’m using the POST method in the main window. When I click on Body I see the JSON payload which in this example is configuring Leaf 1 in our fabric.

Now, just looking at the JSON code, especially if you’re not familiar with JSON or XML can be a bit intimidating. The first question people usually ask is where do I get this code from? You can absolutely read the documentation and figure out how to make your own code. You can also get on and check out the ACI code already available there. However, the coolest option with ACI is that you can use what is called the API Inspector. The API Inspector will actually record the tasks you do manually in the APIC GUI and give you the XML code output so that you can re-use it later.

To use the API Inspector:

  1. Login to the APIC GUI
  2. Click on Admin in the upper right corner
  3. Select Show the API Inspector
  4. Minimize the API Inspector
  5. Do whatever task you’d like to record in XML, like adding a switch to the fabric, creating a Bridge Domain or End Point Group, etc.
  6. Bring the API Inspector back up and find the right payload.
  7. Copy and paste the XML or JSON code into POSTMAN and save it for later use!

In the video below I show an example of setting up an ACI fabric with two spine switches and two leaf switches. It shows me authenticating to the APIC and then running four scripts to join each switch to the fabric. Now, this could all be done in one script as well, if we wanted to, but this shows it in a more understandable way.

Please check out the video below and if you have any questions please post them in the comments below or reach out to me on Twitter @Malhoit.

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top