Mock matches the wrong example using x-mock-response-name

Using a mock server, if I have two sample responses with the same name, if I use x-mock-response-name “200 - ok” and a POST to address B, it still returns the response from A.

If I change “200 - ok” in A to “200 - oks,” it returns the correct response from B.

Is this normal?

1 Like

Hey @tomaszmosko :waving_hand:

Welcome back to the community :trophy:

When using the x-mock-response-name header, if you have multiple examples with the same name, Postman will sort the examples by id and return the first one in the list. The header doesn’t currently allow you to target a specific example of the same name, that is under a different request.

You can read more about this in the Postman documentation.

To make sure you get the intended response, you have a couple of options:

  • Use a consistent and contextual naming convention so each example has a unique name.
  • Alternatively, use the x-mock-response-id header and pass the example’s unique element ID to directly target the one you need.

Each element in Postman has its own unique ID. You can find an example’s ID by opening the active example tab and selecting the info icon.

1 Like

Ok, that’s clear to me.

1 Like