I am using Postman mock server to create a mock endpoint where I need the response of the request to contain the request parameter as well as few other key values.
For example if my endpoint is /test?id=123 then i need the response as
{
"id":"123",
"name":"anyRandomName"
}
Similarly, when I hit /test?id=234 then the response should be
{
"id":"234",
"name":"anyRandomName2"
}
One way to achieve this is by making 2 endpoints with specific query parameters, in this example /test?id=123 and /test?id=234 . But i am looking for a way where i can read the request parameter just like {{$id}} or something like this. Postman do provide keywords like {{$randomAlphaNumeric}} which returns random strings but this will change in every hit.
You can pass the example name in headers while making a call to the mock API with key "x-mock-response-name". this will return the example set with that name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.