Make "Path Variable" required for Sending the request

Hi Team,
I have a Path Variable (imported as openapi) but I can Send the request if the field is empty.
(In Swagger this is not possible, as there is a field validation (empty))
Is there any option in Postman to force users to fill out the required field before send?

Hi @mandrasdt

Welcome to the community :wave:

Looks like we have a long-standing feature request for this:

Similar request on documentation here.

You can prevent the request being send to server by throwing an error in pre-request script:

pm.request.url.toJSON().variable.filter((elem) => elem.value === "").map(elem => elem.key).includes("v2") ? (() => {throw Error("Please provide path parameter v2")})(): null

This code will check if the path parameter v2 (eg https://something/:v2/something) has a value provided else throw the error


1 Like