Importing a CSV file into an EA list using Postman

I have a customer that did not have access to run a Python Script so I came up with the idea of using Postman to do it.  The list of values was in the form of a CSV file.

 

  • Steps
    • Create EA “Names”
    • Install Postman
    • Get EA _ref
    • Convert CSV to JSON
    • Put EA _ref

Create an EA in NIOS

 

Log into your NIOS box and create an EA with the name of “Names” type of List and add a value “Testvalue”

 

1.png

 

Install Postman

 

Go to https://www.getpostman.com download it for your OS and follow there install guide

 

Get EA “_ref” from Infoblox

 

We are going to use “Postman” to make an API call my Infoblox appliance to call an Extensible Attributes called “Names” which is a list.

 

Here are a few screenshots on how to configure “Postman” to get the EA “_ref”

 

Make sure SSL certificate verification is turned off in Postman settings or preferences.

 

2.png

 

 

3.png

  • Use “Basic Auth” then add username and password

 

4.png

    1. For “Headers” we need to add Key “Content-Type” value “application/json”
    2. 5.jpg
      1. For the Body select “raw” and make sure “JSON(application/json) and value {“name”:“Names”}
    3. 6.jpg
      1. Now we hit “Send” and get the results the data we are looking for is the “_ref” value “extensibleattributedef/b25lLmV4dGVuc2libGVfYXR0cmlidXRlc19kZWYkLk5hbWVz:Names" we will use this in our next “Postman” call

Convert CSV to JSON

  • Here is what the CSV looks like:
    • 7.jpg
    • Found this great site to convert CSV to “Many” in my case I want to convert CSV-to-JSON - http://www.convertcsv.com/csv-to-json.htm
    • Copy the content to Step 1 at convertcsv.com
      • 8.jpg
      • Click at the bottom convert to CSV to JSON
        • 9.jpg
      • We get a very useful format that we can use in “Postman”, only thing instead of “Site” we need it to state “value”, so let’s redo the converting process with a change in “Step 1” at convertcsv.com
        • 10.jpg
          • Change “Site” to “value” now we generate a new output
          • 11.jpg

 

Update the EA using “_ref”

So now we are the “_ref” for the EA:Names and the data formatted into JSON we will make a PUT call using “Postman”

  • We will create a new API call
  • 13.jpg
      • “Content-Type” equals “application/json”
      Now for the Body we paste in the converted JSON output from www.convertcsv.com
    • 14.jpg
    • Notice that we are in the Body tab and make sure you select “JSON(application/json) and another thing to take note of my pasted data looks different from the original screenshot after the converted text.
    • {
      "list_values": [
      {
      "value": "JFK"
      },
      {
      "value": "DEN"
      },
      {
      "value": "SLC"
      },
      {
      "value": "LAX"
      }
      ]
      }
    • The reason for that is we are adding data to a “list” so we have to say here is the “list of values”(list_values)
    • Now we hit SEND and it will create the List that we need in Infoblox - "Status" message of 200 OK!
    • 15.jpg
    • If we did everything correctly you will see something like above
    • Now we login into Infoblox and we will see our List with the data we passed in via an API
    • 16.jpg

 

Appendix:

 

Postman Collection have been added download under Attachments rename it to json- Thanks to Chad Willard 

Tagged: