Postman Mock Server matching algorithm logic for request body param
Asked Answered
B

1

6

I have two scenarios for the following API URL.

POST http://{{ip_port}}/oauth/token

  1. When I put the user name and password correctly, it should return 200 and mock json response.

  2. When I put user name and password incorrectly, it should return 401 and mocked json(error).

In Postman Mock server, I noticed that there is no matching algorithm logic for request param.

I want to filter by request param and return related mock responses. I don't want to add two URLs(/token and /failedtoken) for above scenarios.

Currently Postman only support three logic for matching algorithm logic.

  1. Properly formatted responses
  2. HTTP method
  3. Filter by URL

Is there any way to add only one URL for many scenarios in Postman Mock Server?

Blueweed answered 8/5, 2019 at 7:13 Comment(0)
H
10

Postman Mock Server now supports matching by request body. You can use it by specifying a custom header (x-mock-match-request-body to true).

You can also check out an example that demonstrates how this feature works by going to New->Templates and searching for Request Body Matching.

Highlands answered 8/5, 2019 at 8:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.