1. Home
  2. Knowledge Base
  3. Automation
  4. Automation Course Part 4 – Postman Basics

Automation Course Part 4 – Postman Basics

Welcome to the next article in our API development series! In this article, we will cover how to use Postman to prototype API calls and generate sample data, and then generate PowerShell code to begin developing your desired functionality.

Postman is a popular tool that is widely used by developers to test and prototype API calls. It provides a user-friendly interface that allows you to easily create and send API requests, and view the responses returned by the API. In addition, Postman can generate sample code in various programming languages, including PowerShell, that can be used to implement the desired functionality.

In this article, we’ll be using the free fake API from {JSON} Placeholder. So you can follow these steps in Postman yourself and get your first sample data!

Here are the basic steps for using Postman to prototype API calls and generate sample data:

Step 1: Install Postman

The first step is to download and install Postman from the official website ( Postman is available for Windows, Mac, and Linux.

Step 2: Create a new collection

Once you have installed Postman, open it and create a new collection. A collection is a group of related API requests that you can organize and execute together.

Step 3: Create a new request

Next, create a new request within the collection by clicking on the “New” button and selecting “Request”. Enter the API endpoint and method, and add any necessary headers and parameters.

Configure authentication, ideally at the Collection level, if needed (this mock API doesn’t require authentication).

Step 4: Send the request and view the response

Send the API request by clicking on the “Send” button. Postman will display the response returned by the API, including any data or errors.

Step 5: Generate sample code

Once you have verified that the API request is working correctly, you can generate sample code in PowerShell by clicking on the “Code” button and selecting “PowerShell” from the drop-down menu. Postman will generate PowerShell code that you can use as a starting point for implementing the desired functionality.

Paste it into your PowerShell console of choice, and confirm you get the same results.

That’s it! There’s a lot more Postman can do, but this gets you started with using Postman to quickly test connectivity to an API and generate PowerShell code you can use to build working tools.

Now, let’s put together some of what we’ve learned so far, and play with this mockup API a bit! Below are some examples, but play with the documentation and see what other things you can come up with.

GET just a specific user by id:

GET all posts:

Get posts for a specific user using a nested route:

Get comments for a specific post using a filter parameter:

Create a new Post (using a POST request):

Update a Post (using the PUT method):

Delete a Post (using the DELETE method):

Related Articles