Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (2024)

If anything on this page is unclear, please ask in the #learning-apis channel in the FOLIO Slack community.

What is Postman Visualizer?

Postman Visualizer is a tool in Postman that allows you to render the JSON responses from FOLIO in easier to understand visual formats, like tables and bar charts.

https://learning.postman.com/docs/sending-requests/visualizer/

You essentially add extra javascript code to the tests that you can run in the Postman tool to output it in different formats.

Postman offers training and info on it on the page above, but their examples are more than a little complicated for what we might want to do. So I'm just going to detail an example of how I used this tool to output permissions information in tabular format, which I could then copy/paste super easy into an excel spreadsheet.

A note that this is a really helpful technique to just get some fields from a record - you don't have to map every field that comes back in JSON into your visualized table, only the fields you want to extract to Excel.

Step 1: Set up an API call in Postman that successfully returns the data you want to visualize.

In this case, I'm going to set up a call to the Permissions API to get a list of the permissions available in the local development environment running Fameflower. (Input your own URLs, tenant and token values as appropriate.)

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (1)

I added a parameter of length=10000 because FOLIO's default parameter is 10, so it needs to be tons longer in order to get all the results back.

Step 2: Set up your visualization

This is the part I had the most trouble with because I am definitely not a programmer. But hopefully it can make sense.

Go to the Tests tab in your Postman API connection.

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (2)

This is your basic setup for using Visualizer.

You have a part at the beginning:

var template = ``;

This is where you put in your code for the visualization you want to show up. It's essentially like extended HTML.

Then the code underneath that:

// Set visualizerpm.visualizer.set(template, { // Pass the response body parsed as JSON as `data` response: pm.response.json()});

is what spits out the visualization.

SO, because I want to make a table show up, I'm going to put code in that var section that looks a lot like HTML for making a table. It looks like this:

var template = ` <table bgcolor="#FFFFFF"> <tr> <th>Display Name</th> <th>Permission Name</th> <th>Sub Permissions</th> <th>Child Of</th> </tr> {{#each response.permissions}} <tr> <td>{{displayName}}</td> <td>{{permissionName}}</td> <td>{{subPermissions}}</td> <td>{{childOf}}</td> </tr> {{/each}} </table>`;

So what I think is happening here is that you put in the table code, and the table headers just like you would expect.But for the table rows, you get to use this magic{{#each response.SOMETHING}} loop to format the JSON data!

The excellent thing about this is that you can change the order of the JSON fields. So in this example, I have Display Name showing up first in the table, when in the JSON permission name shows up first.

Also, depending on the structure of the JSON, you would change theresponse.permissionspart to specify which part of the record should be iterated over. So a JSON for a permission record on the top level is one big record enclosed in{} and within it, a record named "permissions" that is an array of individual permissions entries. I want it to loop over those individual permissions entries, so I use response.permissions.

So to sum up, this is everything that is in the Tests tab:

The full content of the Tests Tab

var template = ` <table bgcolor="#FFFFFF"> <tr> <th>Display Name</th> <th>Permission Name</th> <th>Sub Permissions</th> <th>Child Of</th> </tr> {{#each response.permissions}} <tr> <td>{{displayName}}</td> <td>{{permissionName}}</td> <td>{{subPermissions}}</td> <td>{{childOf}}</td> </tr> {{/each}} </table>`;// Set visualizerpm.visualizer.set(template, { // Pass the response body parsed as JSON as `data` response: pm.response.json()});

Step 3: Test Your Visualization and View Your Output

So now you run your API!

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (3)

To get to the Visualizer, scroll down to the Body section, and instead of clicking on Pretty or Raw to get the JSON, click Visualize.

Then to copy the output to Excel, click in the window, do a CTRL-A CTRL-C (select all and copy), and then in Excel, paste it as "match destination formatting." If that doesn't work, try Paste Special > text to paste without any formatting.

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (4)

Tip: Handling nested JSON fields

There will be times when your JSON data will include nested fields. For example, Loan Types:

 { "id": "", "name": "", "metadata": { "createdDate": "", "createdByUserId": "", "updatedDate": "", "updatedByUserId": "" }

To include those in your Visualizer script, reference the parent and the child in your TD elements like so:

 <td>{{metadata.createdDate}}</td> <td>{{metadata.createdByUserId}}</td> <td>{{metadata.updatedDate}}</td> <td>{{metadata.updatedByUserId}}</td> 

Another Example: Visualizing "normal" and nested fields in a table

(Discussed in Slack July 2023: https://folio-project.slack.com/archives/CQ7EK52LB/p1688134681791399)

In this little example i wanted to know which external IDs belong to each title in instance-storage/instances (using the development environment Snapshot). As final result i wanted to display/visualize all titles from instances with each corresponding external ID, so that i can put the data in an easy-to-use Excel table. Hopefully, this example will be helpful - especially for non-programmers (e.g. for librarians like me : )). Thanks to Owen Stephens for helping out with the code!

This is the GET request (with default login data for Snapshot):

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (5)

Let's have a look at the response first, to identify the required fields:

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (6)

So, we see that the top level data is "instances". For the desired table which i want to visualize, i am needing "title" from "instances" and also "value" inside "identifiers" inside "instances".

This is the code in the Tests tab:

The full content of the Tests Tab (instances-example)

var template = ` <table bgcolor="#FFFFFF"> <tr> <th>Title</th> <th>External ID</th> </tr> {{#each response.instances}} <tr> <td>{{title}}</td> <td>{{#each identifiers}}{{value}},{{/each}}</td> </tr> {{/each}} </table>`;// Set visualizerpm.visualizer.set(template, { // Pass the response body parsed as JSON as `data` response: pm.response.json()});

As you can see it's very similar to the code used in the example above on this page (permissions example). The difference is 1. that #each response is set to loop trough the data from "instances": {{#each response.instances}} and 2. after the iteration trough instances and before {{value}} we type {{#each identifiers}} to iterate over the data inside {{value}}. So in total we need 2 loops trough the data. First trough "instances" (top-level) and then trough "identifiers" (which is inside "instances" and contains a nested field "value").

The final result looks like beneath - the left column of the table shows all the titles. The right column shows all external IDs from each title.

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (7)

Use Postman Visualizer to get JSON into a format for Excel - Information and User Guides for FOLIO Apps (2024)
Top Articles
Bankruptcy Petitions - Francis Wilks & Jones Solicitors
▷ Definition and characteristics of formal education | isEazy
Foxy Roxxie Coomer
Oldgamesshelf
Sprinter Tyrone's Unblocked Games
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Visitor Information | Medical Center
CLI Book 3: Cisco Secure Firewall ASA VPN CLI Configuration Guide, 9.22 - General VPN Parameters [Cisco Secure Firewall ASA]
Ati Capstone Orientation Video Quiz
Puretalkusa.com/Amac
Is Csl Plasma Open On 4Th Of July
The Haunted Drury Hotels of San Antonio’s Riverwalk
Does Pappadeaux Pay Weekly
Declan Mining Co Coupon
Large storage units
Hillside Funeral Home Washington Nc Obituaries
D10 Wrestling Facebook
Abby's Caribbean Cafe
Trivago Sf
UPS Store #5038, The
Indystar Obits
Best Mechanics Near You - Brake Masters Auto Repair Shops
U Of Arizona Phonebook
South Bend Weather Underground
Cardaras Funeral Homes
Nottingham Forest News Now
Leben in Japan &#8211; das muss man wissen - Lernen Sie Sprachen online bei italki
manhattan cars & trucks - by owner - craigslist
Rs3 Bring Leela To The Tomb
897 W Valley Blvd
Plasma Donation Racine Wi
Redding Activity Partners
Bad Business Private Server Commands
Cars And Trucks Facebook
Robot or human?
Senior Houses For Sale Near Me
Junior / medior handhaver openbare ruimte (BOA) - Gemeente Leiden
Linabelfiore Of
Go Upstate Mugshots Gaffney Sc
Legit Ticket Sites - Seatgeek vs Stubhub [Fees, Customer Service, Security]
Wlds Obits
Craigslist Pa Altoona
Lucifer Morningstar Wiki
[Teen Titans] Starfire In Heat - Chapter 1 - Umbrelloid - Teen Titans
Stosh's Kolaches Photos
Gas Buddy Il
Frequently Asked Questions
Bedbathandbeyond Flemington Nj
What Does the Death Card Mean in Tarot?
A Snowy Day In Oakland Showtimes Near Maya Pittsburg Cinemas
Gummy Bear Hoco Proposal
Maurices Thanks Crossword Clue
Latest Posts
Article information

Author: Rueben Jacobs

Last Updated:

Views: 5827

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rueben Jacobs

Birthday: 1999-03-14

Address: 951 Caterina Walk, Schambergerside, CA 67667-0896

Phone: +6881806848632

Job: Internal Education Planner

Hobby: Candle making, Cabaret, Poi, Gambling, Rock climbing, Wood carving, Computer programming

Introduction: My name is Rueben Jacobs, I am a cooperative, beautiful, kind, comfortable, glamorous, open, magnificent person who loves writing and wants to share my knowledge and understanding with you.