Postman Tutorial Part 32 – Retrieve Query Parameter Value in Tests Script in Postman
We have already seen usage of Query params in API. We may need to retrieve query parameters value in Tests and Pre-request Script for validation. So in this post, we will see how can we retrieve query parameters value.
pm.request.url.query.get()
pm.request.url.query.all()
pm.request.url.getQueryString()
Let’s see above concept in an example:-
Let’s add params to API:-
Add script to Tests:-
Hit and see Postman Console:-
Import above example from below collection:-
https://www.getpostman.com/collections/531abaa3ed7ce38c9d9b
Refer basics of API Testing here.
Refer detailed tutorial of Postman here.
More about API Testing in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading
#HappyApiTesting