Can I create a baseURL in collection level in postman, and in the requests just put the path?
For example I have a Customer Collection (Folder)
Inside there is a GET/ customers
instead of writing in the customer collection, in each request the baseURL
I want to declare it the collection, and in the GET/ customers
, Where I put the url
Just put the path ( /customers
)
pm.request.url returns a object with fields host, path, and params .
You can replace the whole object with a string or the individual elements.
An example using Postman Echo.
Then in the pre-request script (which you can set at the request, folder or collection level).
pm.request.url.protocol = "https";
pm.request.url.host = "postman-echo.com";
The resulting console log where you can see that the protocol and host have been transposed appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With