Using Pre Request Script in Postman

Postman has become the default option to make and test API requests. Although we might be familiar with making basic http requests with postman, it gives us a lot more power in terms of programming things around an API request. In real world scenarios there are three ways we handle params and process them further.

First is when the params are just user inputs and you can plainly use for further processing like fetching from DB.

Second use case is when the params themselves are computed on clients and then sent to servers. These can be a things like generating a signature containing timestamps so they will be different every time.

Third is when your clients chain requests i.e. they make an API call and use the response of this API call as the params of next API call.

While the first use case is fairly simple to test on postman, second and third cases are tricky.

We will try to look at how to automate these issues using Pre Requset Scripts in postman in the article Using Pre Request Script in Postman