Reputation: 35434
In brief
In Postman, at mock server, and at a specific request with multiple saved example, how to pick up an example in the middle of the example list instead of the first one?
Full details
Let's say we have an api endpoint GET /users
and it has three examples saved e1, e2, e3 - listed in that order ie e1
on top in the example list.
And we create the mock server, called M
, for the collection in Postman.
Currently when calling this endpoint thru this mock server M
, we will get mocked response as e1
.
My question is how can we specify e2
instead as mocked value?
Upvotes: 0
Views: 1521
Reputation: 318
You can do this in 3 different ways, all documented here - https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mock-with-api/
TLDR; you can send one of the following 3 headers along with your request:
x-mock-response-code
, if each of the three example responses has a different response code, you can specify the desired response code as the value of this header.x-mock-response-name
, you can specify the name of the desired example.x-mock-response-id
, you can specify the uid of the desired example (<user-id>-<response-id>
)Upvotes: 2