Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set In Postman Collection BaseURL

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 )

like image 785
Yaron Avatar asked Oct 12 '25 12:10

Yaron


1 Answers

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.

enter image description here

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.

enter image description here

like image 74
mikee Avatar answered Oct 16 '25 07:10

mikee