# How to form dynamic responses using postman mock server based on request params

**URL:** <https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161>\
**Category:** Help Hub\
**Created:** [July 15, 2020, 10:34am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161 "2020-07-15T10:34:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdxcz](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cdxcz](https://community.postman.com/u/cdxcz)\
**Post date:** [July 15, 2020, 10:34am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/1 "2020-07-15T10:34:28Z")

</div>

I am trying to form dynamic responses based on request params using postman mock server  
Please help me. Any links or direct answers much appreciated

---

<div class="post-metadata">

**Author:** ![darren.capner](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/darren.capner/32/4730_2.png) [@darren.capner](https://community.postman.com/u/darren.capner)\
**Post date:** [July 15, 2020, 1:06pm UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/2 "2020-07-15T13:06:13Z")

</div>

The postman mocks documentation found on this page [https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mocking-with-examples/](https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mocking-with-examples/) mentions that mock responses only return examples that match the following request criteria:

\*URL endpoint  
\*request method type,  
\*status code

‘Your examples might vary depending on the URL endpoint, request method type, or status code. If you have multiple examples saved to the same mock, you can choose to save each example under a unique URL endpoint like you saw in this example with `/get` and `/test` . Alternatively, if you have saved examples with different response status codes, you can send an authenticated request to the mock endpoint along with the `x-mock-response-code` header specifying which integer response code your returned response should match.’ - Postman Documentation

I agree that having request parameters and request query string matching would also be very helpful to match against examples to return.

Update: [pallab.nag](https://community.postman.com/u/pallab.nag) below mentioned that on the page provided, below there is a separate section that mentions query parameters also can be used to return matching examples.

---

<div class="post-metadata">

**Author:** ![cdxcz](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cdxcz](https://community.postman.com/u/cdxcz)\
**Post date:** [July 15, 2020, 1:13pm UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/3 "2020-07-15T13:13:54Z")

</div>

means to differentiate each example, there should be definitely some uniqueness in url or request body or headers?

---

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [July 16, 2020, 12:34am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/4 "2020-07-16T00:34:14Z")

</div>

@cdxcz,

What do you mean by “dynamic”?

If you just want different responses based on different request parameter values, add those request parameter values to the example. You’ll need multiple examples, one for each variation.

Best,

Kevin

---

<div class="post-metadata">

**Author:** ![cdxcz](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cdxcz](https://community.postman.com/u/cdxcz)\
**Post date:** [July 16, 2020, 2:14am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/5 "2020-07-16T02:14:30Z")

</div>

thanks i got some idea

---

<div class="post-metadata">

**Author:** ![cdxcz](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cdxcz](https://community.postman.com/u/cdxcz)\
**Post date:** [July 16, 2020, 8:46am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/6 "2020-07-16T08:46:36Z")

</div>

how can i validate request body  
like i want to check if the request has few keys irrespective of values?  
ex : if(pm.request.body.has(“key1”)  
{  
//do something  
}  
is it possible

---

<div class="post-metadata">

**Author:** ![pallab.nag](https://avatars.discourse-cdn.com/v4/letter/p/49beb7/32.png) [@pallab.nag](https://community.postman.com/u/pallab.nag)\
**Post date:** [July 22, 2020, 8:13am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/7 "2020-07-22T08:13:16Z")

</div>

@darren.capner although  
[https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mocking-with-examples/](https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mocking-with-examples/) here it is defined that different response based on query params is available but its not working .

---

<div class="post-metadata">

**Author:** ![aejaz.h](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@aejaz.h](https://community.postman.com/u/aejaz.h)\
**Post date:** [May 14, 2021, 11:46am UTC](https://community.postman.com/t/how-to-form-dynamic-responses-using-postman-mock-server-based-on-request-params/14161/8 "2021-05-14T11:46:15Z")

</div>

did you got to test it?  
is it feasible?
