Mock Server - Dynamic response with request variables defined by API callers

Hi, I want to let user call API like /api/items/:id which is a mock server,

the api callers can call /api/items/101 or what integer they like as the path variables,
then the response will be like it:
{"id":"101","status":true}. The β€œ101” will be changed as same as :id

I knew there is a way was like:

But it sets up a single one testable example,
if I want to have 102, 50, 200 different item ids,
I need to create at least 3 examples with setting {{item_id102}},{{item_id50}} and so on.

So, I want to know if there a way to return a response which is generated according to the request automatically?
Thank you.

1 Like

You can use the postman api to update the variable , this helps in creating dynamic response

So just update the environment variable from pre request script

1 Like

Thank you,
I can do it successfully with your suggestion.
I thought there would be some way to do it directly on the postman mock server or example,
it is sad that It doesn’t have.

And some notes for the others,
you can find the environment id at the details tab under the current environment window(If you are viewing it)

1 Like