8/16/2023 0 Comments Postman websocketSuppose you have 2 APIs, and to execute the second API, you need to pass a token from the response of the first API. Request Chaining is one of the easiest ways to increase your productivity. They can be used to perform assertions, set or remove variables etc. Tests scripts are executed after the request is made. Pm.t("currentDate", moment().format("DD/MM/YYYY")) One of the main usages of the pre-request script is to make your request more dynamic.įor example, if a request requires the current date, we can use the moment library to get the current date before passing it to the request body. Understanding Pre-request Script and Tests Script Pre-request ScriptĪs the name implies, the pre-request script is executed before the request is made. Instead of googling for the Online UUID Generator Tool, I can use this helper request to generate random UUID from Postman itself. I recommend to take a look at the Dynamic variables section to take full advantage of this feature.įor example, I sometimes need a random UUID. We can use dynamic variables to generate random test values like random UUID, names or timestamps. Dynamic Variablesĭynamic variables | Postman Learning Center Otherwise the variables will be empty, and your peers will have to reverse engineer these values somehow. If there are some constant variables that are essential to the collection, we should set them as collection variables before sharing the collection with others. When we share our APIs to other developers, we often only share the collection without the environment (as it may contains other irrelevant variables). Tip: We often set different environment variables in our local workspace. For example, if baseUrl is declared in both Collection and Environment level, the value from the Environment will take precedence. If a variable with the same name is declared in two different scopes, the value stored in the variable with the narrowest scope will be used. Postman supports the following variable scopes: ![]() Variable scopes | Postman Learning Center In my examples below, I will cover some tips and tricks of using Postman using only features available from the free plan. ![]() I realised I needed to do a deep dive on Postman to take advantage of its latest features. ![]() Sorting through these collections is taking a toll on my productivity. Some of these collections contain the same APIs, but different authors create them with different variable naming conventions etc. However, as I collaborated more with other fellow developers from my team, my Postman workspace is starting to clutter with many Postman collections. I was using the basic features of Postman to perform HTTP requests to check API behavior etc. I just completed Postman's 30 Days of Postman and Valentin Despa's Postman course on Udemy in February 2022.īefore embarking on these courses, I was literally using Postman on a need-to-know basis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |