![]() Monitorĭuring your development work, you may find a need to check whether certain APIs are working correctly or alive periodically. Note that there is a limit of 1000 mock calls per month for free plan users. For more info: Understanding example matching We cannot match the request body or query parameters. However, I find that the actual use case is fairly limited as there are known limitations of Postman mock servers. When you send a request to a mock server, Postman will match the request configuration to the examples you have saved and respond with the data you added to the example. ![]() In this case, we can consider mocking the APIs so that any development work can continue in parallel. The API specifications are mostly finalised, but the APIs are pending implementation. Imagine a case where you are working on a set of APIs that other developers are dependent on or vice versa. This means that we can directly import API specs from API editors such as SwaggerHub into Postman and create mock APIs. Postman supports different API specifications such as OpenAPI 3.0. Encode URI ComponentĮxercise to try: Day 18: API Specifications With that being said, there are times when we need to know advanced assertions when dealing with complex datasets. Instead of copying and pasting the values every time you run these APIs, you can use request chaining to automate this process for you.Īfter going through the 30 Days of Postman, I realise most of the use cases are covered by the provided snippets in Postman, making it handy to know which snippets are available instead of reinventing the wheel with custom scripts. Suppose 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. Understanding Pre-request Script and Tests Script.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |