Recently I have worked on how to create a simple Web API service to manage a list of country capitals. I thought it would be beneficial to some if I put together a quick post to show how to test it using postman.
What is Postman?
Postman is a free API debugging tool which makes working with APIs faster and a bit easier. If you don’t already have it installed, feel free to download it so you can follow along.
How do you get Postman?
Postman is free and you can download it at “https://www.getpostman.com/“. Simple download it and following the instructions for the installation. After successful installation, open it and select HTTP Method and enter the URL of the Web API as shown below.
We’ll test the following commands:
Get all countries
Get a specific country by ID
Add a new country
Update an existing country
Delete a country
Let’s add a few countries to the list.
I have submitted 6 countries. Let’s get the list of countries that were submitted using the GET verb in Postman.
To find a specific country I need to fetch it by sending the ID in the URL. See below for more.
Let say I want to change the first country information because of an typo or maybe I just want to change it to a whole different country.
I need to send a PUT to do so.
Let’s verify to see if the first country in the list has been changed.
Now let’s try the delete to see what happens.
After deleting country 1, 2, 3,and 4 we now have 2 countries left.