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.

1 Like