postmanmockserver

Postman mockserver Adding Examples


Imagine a scenario where i have a "sales" endpoint. It can be further filtered on say by region i.e europe and america

Steps i followed

  1. I created mock server and created sales/{{customregion}} like shown below

createms

2)named the mockser testms

3)now i click on the request and then click on Examples on top right . I rename default to europe and add another eg as america

enter image description here

  1. same way i created random json response sample for america as well

enter image description here

  1. Now my question is below If i mistype the endpoint i still get the result. Let's look at each case

Eg1)https://21ad39c9-aebc-49a5-88d0-8e1abad0a2d8.mock.pstmn.io/sales/europe result as expected gives data configured for europe Same works for america as well i.e it gives results configured for america

Eg2)instead of europe i give europes and it still works ..how ??eg below

enter image description here

Eg3) Same way i gave eurospe instead of europe and that worked too.

Eg4) only if i mistype it completely it gives below error which is correct

enter image description here

whole thing has got me a little confused. First how does {{customregion}} variable works and how it works even if there is a typo. But if misspelled, may be more than 1 character it gives an error. Can anyone please explain this in detail


Solution

  • In case of a mispelled route Postman tries to return the "closest" matching example route as a fallback. It is not possible to predict this deterministically.