Matching POST request BODY

Hello,

I am using mock-server to test post and get requests. I have created various examples for a get request that match with the query parameter and the correct response is received.

However, when using POST requests, can responses be sent based on content in the request body?

Thanks.

I don’t think mock servers support matching by request body yet, you can open a feature request in the issue tracker on github for the same.

Meanwhile, you could use custom headers like x-mock-response-name and x-mock-response-id for matching. It is explained in a little more detail in this answer.

Feel free to ping here in case you need some help in setting this up and I or someone else from the community would be happy to help. :slight_smile:

Thank you. I will use this approach.

Please note that this approach is not really optimal, as it forces you to modify your request to include additional headers.

It would be great if the Postman team could invest some time to improve the matching algorithm to make it work for such scenarios as well.

3 Likes

The feature would be really good! Adding an extra header just to work with the mock server is not an optimal solution.

Agree. This feature is very needed

Hi @ivorobioff and everyone reading this. Thanks for requesting features that will improve your experience as a Postman user. We are not using this Community forum for feature requests, however, so please note the following guidelines:

Have an idea for a new Postman feature or enhancement? Submit your feature request on GitHub . :rocket:

Check out the Postman Roadmap for Developers for a sneak peek at what’s coming up.

Search for an existing feature request to see if there’s one similar to yours. If you see your suggestion already requested, feel free to add a “+1” reaction and we will keep a note of it. This helps Postman keep track of all the features requested and respond when the feature is released into production.

I’m going to close this thread now, so if you have specific questions or advice on how to work around your current problem, please start a new thread. Thanks :slight_smile:

2 Likes