I have a simple GET
method in Postman:
{
"requestId": 200
}
For simplicity I wanted to return 200 response on requestId
200 and 400 on requestId
400 and I'm not able to do that in Mockoon 6.1.0.
I have 2 responses for one route with a rules
Body $.requestId equals 400
(value 200/400 is different if rule for first request and for second)
Rules from JSON file:
{
"rules": [
{
"target": "body",
"modifier": "$.requestId",
"value": "200",
"invert": false,
"operator": "equals"
}
],
"rules": [
{
"target": "body",
"modifier": "$.requestId",
"value": "400",
"invert": false,
"operator": "equals"
}
],
}
I always get response 200.
I think this is due to the fact that your requestId
field is a number. It appears the "equals" rule plays well with strings but not numbers.
As a workaround you can select "regex" in the comparator list.