How to create a collection in Postman

Guide to Creating a Collection in Postman

Mastering Postman Collections for Advanced Networking.

Hi everyone,

Creating a collection in Postman is a crucial step in automating and streamlining API workflows. Here's a guide to help you create a collection and perform tasks related to creating a Tenant and configuring Networking components (Tenant, VRF & Bridge Domain). It is broken down into 3 Major Steps (Creating a Collection, Creating Requests within the Collection, and Executing/Running the Collection). Let’s take a look at the 3 Steps.

Step 1. Open Postman and Create a New Collection

To Create a collection, execute the following steps:

  1. Click on the "New" button in the top left corner.
  2. Select "New Collection".
  3. Name it "Tenant Configuration".

Once the collection is established, the next step is to create scripts by generating "Requests."

Step 2. Add Requests to the Collection

Request 1: Create a request to log into the APIC

The 1st request you need to create is a script for providing the credentials to log into the APIC. This request will be used by the subsequent requests to log into the APIC.

To create the request, execute the following steps:

  1. Click "..." under the collection & click "Add request".
  2. Name it "APIC Login".
  3. Create the request based on the following:

    Method Type: POST

    URL: https://apic1.kbits.live/api/aaaLogin.json

  • apic1.kbits.live is the URL for your APIC.
  • The API endpoint responsible for logging into the APIC is called aaalogin.json
  • Authorization:

  • Type: Basic Authentication
  • Username: admin
  • Password: Cisco@12345 [The APIC Password]

    Header:

  • Key: Content-Type
  • Value: application/json

Body:

  • Type: raw
  • {
    "aaaUser": {
        "attributes": {
            "name": "admin", "pwd": "Cisco@12345"
        }
    }
    
    }

    Request 2: Create a request to Create a Tenant

    The 2nd request you need to create is a script to create a Tenant. This request will use the Login request to log into the APIC. To create the request, execute the following steps:

    1. Click "..." under the collection & click "Add request".
    2. Name it "Create Tenant".
    3. Create the request based on the following:

      Method Type: POST

      URL: https://apic1.kbits.live/api/mo/uni.json

    • apic1.kbits.live is the URL for your APIC.
    • The API endpoint responsible for creating a Tenant is named uni.json.
    • "mo" is short for "managed object"
    • "uni" signifies a "universal object."
    • Authorization:

    • Type: Inherit auth from parent
    • [This specifies that the login information will be inherited from the 1st request]
    • Header:

      • Key: Content-Type
      • Value: application/json
    • Body:
      • Type: raw
      • {
        "fvTenant": {
            "attributes": {
                "name": "KBITS", "rn": "tn-KBITS", "status": "created"
            }
        }
        
        }

    Request 3: Create a request to Create a VRF

    The 3rd request you need to create is a script to create a VRF within the Tenant. This request will use the Login request to log into the APIC. To create the request, execute the following steps:

    1. Click "..." under the collection & click "Add request".
    2. Name it "Create VRF".
    3. Create the request based on the following:

      Method Type: POST

      URL: https://apic1.kbits.live/api/mo/uni/tn-KBITS/ctx-GRT.json

    • apic1.kbits.live is the URL for your APIC.
    • "tn-KBITS" refers to the Tenant KBITS.
    • "ctx-GRT" refers to a context (VRF) and GRT is the name of the VRF.
    • ctx-GRT.json is the API endpoint RF named GRT
    • Authorization:

      • Type: Inherit auth from parent
      • [This specifies that the login information will be inherited from the 1st request]

      Header:

      • Key: Content-Type
      • Value: application/json

      Body:

      • Type: raw
      • {
            "fvCtx": {
                "attributes": {
                    "dn": "uni/tn-KBITS/ctx-GRT", "name": "GRT",
                    "rn": "ctx-GRT", "status": "created"
                }
            }
        }
      • "fvCtx" object represents a context or a Virtual Routing and Forwarding (VRF).
      • The Distinguished Name (dn) represents the unique identifier or path for the object within the APIC hierarchy.
      • In our case, "tn-KBITS" represents the Tenant and "ctx-GRT" is the Context within the KBITS Tenant.
      • The Relative Name (rn) provides the relative identifier for the object within its parent container.

    Request 4: Create a request to Create a Bridge Domain

    The 4th request you need to create is a script to create a Bridge Domain within the Tenant. This request will use the Login request to log into the APIC. To create the request, execute the following steps:

    1. Click "..." under the collection & click "Add request".
    2. Name it "Create BD".
    3. Create the request based on the following:

      Method Type: POST

      URL: https://apic1.kbits.live/api/mo/uni/tn-KBITS/BD-BD1.json

    • apic1.kbits.live is the URL for your APIC.
    • "tn-KBITS" refers to the Tenant KBITS.
    • The API endpoint responsible for creating a Bridge Domain is named BD-BD1.json.
    • "BD-BD1" refers to a Bridge Domain and BD1 is the name of the Bridge Domain.
    • Authorization:

      • Type: Inherit auth from parent
      • [This specifies that the login information will be inherited from the 1st request]

      Header:

      • Key: Content-Type
      • Value: application/json

      Body:

      • Type: raw
      • {
            "fvBD": {
                "attributes": {
                    "dn": "uni/tn-KBITS/BD-BD1", "name": "BD1",
                    "rn": "BD-BD1", "status": "created"
                }
            }
        }

    Request 5: Create a request to Link the VRF & the Bridge Domain

    The 5th request you need to create is a script to link the Bridge Domain to the VRF within the Tenant. This request will use the Login request to log into the APIC. To create the request, execute the following steps:

    1. Click "..." under the collection & click "Add request".
    2. Name it "Link-VRF-BD".
    3. Create the request based on the following:

      Method Type: POST

      URL: https://apic1.kbits.live/api/mo/uni/tn-KBITS/BD-BD1/rsctx.json

    • apic1.kbits.live is the URL for your APIC.
    • "tn-KBITS" refers to the Tenant KBITS.
    • The API endpoint responsible for linking the Bridge Domain to a VRF is named rsctx.json.
    • "BD-BD1" refers to a Bridge Domain named BD1
    • Authorization:

      • Type: Inherit auth from parent
      • [This specifies that the login information will be inherited from the 1st request]

      Header:

      • Key: Content-Type
      • Value: application/json

      Body:

      • Type: raw
      • {
        "fvRsCtx": {
        "attributes": {
        "tnFvCtxName": "GRT"
        }
        }
        }

    Step 3: Execute the Collection

    1. Save your collection.
    2. Click on the "Runner" button in the top-left corner.
    3. Select your collection and click "Run."
    4. Review the results to ensure each request is successful.

    By following these steps, you'll have a Postman collection set up to create a Tenant, VRF, Bridge Domain, and link them together. You can then use this collection to automate and streamline your networking configuration process.