What is also not clear to most when they first start using POSTMan is that this feature not only saves time for yourself, but you can SHARE the collection with your team! This is another huge time saver. What isn’t clear to most when they use any rest client is the amount of time spent copying and pasting response values into other requests, especially in a HATEOAS based API where you need to follow link response hrefs to complete various REST API scenarios. Works fantastic! This is a HUGE feature that I have yet to see any other REST client offer. Keep a tab on this blog as well as the Twitter account for more tips and tricks. There are more tutorials planned in this series. Check out the docs for more Postman features. You can download the sample collection and import it inside Postman. As request variables work everywhere, you can build a sequence of API calls which exactly mirror your use case. Test scripts let you extract variables and chain together requests in any way you like. On hitting send, Postman sends the token along with the request. Let’s add a form-data variable to the ‘/status’ request. To send the token, we need to set it as part of the POST request. POST request with the previous session token Hover over the quick look window (q) to check that the variable “token” has the value extracted from the responseģ. tEnvironmentVariable("token", jsonData.token) Īdd this to the test editor and hit send. To extract the token, we need the following code. For this dummy API, the token is needed for a successful POST request on the ‘/status’ endpoint. This request returns a JSON body with a session token. Lets go through an example which will illustrate this in more detail:įor this example, we’ll create and set a blank test environment. You can even add something dynamically generated through Javascript. ![]() All you have to do is call tEnvironmentVariable(key, value) or tGlobalVariable(key, value) to set a variable with values you have extracted from the response. Test scripts dramatically simplify this flow. ![]() This works, but is a lot of work if you have more than a few variables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |