Mock Server: Query Params drive responses


Mock Server is a very powerful feature. It allows for the testing of APIs as they are being developed. It allows for exercising the APIs once they are developed.

In my case, what I actually want to do is simulate failures in a third party API I have zero control over. My primary goal while testing using Postman, is to avoid any code changes to be required for testing (eg: don’t introduce different headers or parameters because that requires code changes and would be an invalid test.) Data changes are fine.

My thinking is:

  1. The paths to be tested remain constant
  2. The parameters determine behavior.

For example: path is /w/get/someInfo

Keeping it simple, the call takes one parameter: ID

I can then set up several examples to simulate the conditions I want to test for. eg:
/w/get/someInfo?id=1 : returns 200, well formed data
/w/get/someInfo?id=2 : returns 200, badly formed data
/w/get/someInfo?id=3 : returns 404, no data //yes, this third party does that (!!!)
/w/get/someInfo?id=4 : returns 500, no data

What I’m proposing is that the first parameter is the discriminator. ie: Postman doesn’t have to have knowledge of the parameters passed, only that the first parameter is the one to match responses on.

If this is already possible, and I’m completely misunderstanding path matching please let me know.

If this is not clear, please let me know.

Thanks in advance.