dustyjuhl / All-Things-Postman

A selection of examples using Postman REST Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All-Things-Postman

Postman Logo

Why create this repository?

I've been using Postman for a while now and I'm still uncovering features that I didn't even know existed - There are a number of How-To guides out there explaining how to use the tool's feature set but as the platform is constantly evolving these can become out of date, really quickly.

My goal is to create a space where I can show examples of some of the many features in the tool and for it to also be a living piece of documentation, that will change over time to reflect the new changes being released.

You can keep up to date with these changes via the Change Log and by subscribing to the Postman Blog.

One of the main reasons why I'm a fan of the tool is the supporting documentation that has been created - Although I will be covering some of the same features I will be including usable content that you can import into your own instance and work through the example at a pace that suits you.


Before I start explaining the many different amazing and wonderful features of Postman, I just wanted to share a couple of links to some alternative REST clients - Just to prove that I'm not completely bias towards Postman :)

A similar tool to Postman and packed full of cool features. The ability to filter the response data is awesome! Alan Richardson Created a great video explaining some of the features of the tool 3 Reasons to use Insomnia REST Client in your Exploratory API Testing.

VSCode extension giving you the ability to make API requests from inside the editor. Really cool!

These are both excellent REST clients and well worth checking out - Ultimately, It's all down to personal preference and It's completely up to you, to find what meets your own requirement, in your given context.


Let's get started!

I've made a huge assumption that if you're reading this you will probably have Postman downloaded and installed on your machine already - If you don't that is not a problem, just head over to the Postman site and grab the flavour that suits your OS. Once you're done - Be sure to come back again. :)

The tool on it's own is quite useless, in order for us to start having some fun and making requests, we need an API with some endpoints that will return some data - This is where a wonderful resource provided by Mark Winteringham comes in handy! Mark has created Restful-Booker, a safe place for people to learn more about API testing and a active platform to try out tools like Postman or any of the other REST clients mentioned.

"Restful-booker is a Create Read Update Delete (CRUD) Web API that comes with authentication features and loaded with a bunch of bugs for you to explore"

I would recommend taking a look through the API documentation to get a feel for the type of requests we will be making within the example guides. We'll get very familiar using the GET, POST, PUT and DELETE verbs and pairing these with the powerful features of Postman.

All the requests that we will be making, will be included in a collection, that can be imported directly into your local Postman application. It will start quite basic but we will be building these collections and incorporating features such as:

  • Environment and Global Variables
  • Preset Headers (Saving you a bunch of time)
  • Pre-Request Scripts (Writing basic JavaScript to create new data with each request and other cool things)
  • Tests (Chai style assertions)
  • In-Built Test Runner
  • Newman command line collection runner
  • Postman Console
  • Using some built in modules like moment and Lodash
  • Many many more...

The format will take the form of a series of individual pages where I will explain in a bit more detail what I'm actually doing in Postman when making the requests and this will be backed up by images, gifs, code snippets etc. to try and make the information come to life. I'm a Tester so you can expect me to make observations along the way and I will be noting these down but the main focus of the examples we always be, using Postman and it's features to request data from the Restful-Booker API.

It will be an ever evolving space so if you would like me to add details covering certain features or to expand the examples in the repository - Please give me a shout @dannydainton I'm always available to chat!


Example Guides

All requests in the examples will be made to the Restful-Booker API - You can find the available endpoints here.

Current Postman version being used: 6.1.3 Windows x64

01 GET /ping

In this example we will send a request using the /ping route to ensure that the API is active and able to receive requests.

02 Create an Environment file

In this example we will be creating an Environment file and using data from this file within our requests.

03 GET /booking

For this example we will be making requests to the /booking route and using some different parameters in the requests to filter the response data.

04 Preset Headers

For this example we will be looking at the Preset Headers feature.

05 Importing Files

In this example we will look at some of the methods of importing various different files into Postman.

06 GET /booking/{id}

In this example we will be getting the data for a single booking from the API. We will explore the endpoint using Request Headers and also taking a basic look at the Pre-request Scripts feature to make our request a little bit more dynamic.

07 Creating our first test

In this example we will be taking our first look at the Tests feature. We will create a basic test to assert against some response data returned from the Restful-Booker API.

08 Extending our tests

For this example we will be taking the knowledge gained from creating our first basic test and extending this to cover more of the response data.

09 Global and Dynamic variables

In this example we'll be looking at how to Create, Use and Clear Global variables. We will also be taking a look at the Dynamic Variables that Postman offers.

10 POST /booking

In this example we'll be using the POST method to send data to the /booking endpoint and create some new bookings based on the information we provide in the request.

11 Dynamically create new bookings

For this example we will be using Postman to dynamically generate data using some of the built-in modules to create new bookings.

12 Introduction to the Collection Runner

In this example we will be looking a bit closer at the Collection Runner which allows us to run a series of requests.


More examples to follow shortly...

I'm currently in the process of updating the images and gifs, this was always going to be the case when creating static content for a living software project like Postman - During the latest updates the UI has changed slightly so the examples will be correct but the visuals might be slightly outdated. As I have added many of these to each example, recreating them is going to be a mission in itself, please bare with me. :)

Upcoming examples will include:

  • Data driven requests from the Collection Runner
  • Request Workflows
  • Collection and Sub-Folder level elements
  • Basic Authentication
  • Mocks
  • Creating documentation for your API
  • And a few more...

As always, I'm available to chat over on Twitter @dannydainton and I've recently started answering questions on Stackoverflow, so if you do have a specific problem, just jump over to there and I'll try my best to help :)

About

A selection of examples using Postman REST Client