Reputation: 11
I am facing issue while getting the response using the Query during the mocking data with Mountebank tool:
Below is the link which I have tired:
GET:http://localhost:6173/entities/?key=first
I want to get the "second" response, but what I'm getting is: "No response".
{
"port": 6173,
"protocol": "http",
"stubs": [
{
"predicates": [
{
"equals": {
"path": "/entities",
"query": {
"key":"first"
},
"method": "GET",
"headers": {
"Content-Type": "application/json"
}
}
}
],
"responses": [
{
"is": {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": [
{
"id": "second"
}
]
}
}
]
},
{
"responses": [
{
"is": { "statusCode": 404 }
}
]
}
]
}
Actual Response: No response
expected response: second
Upvotes: 1
Views: 2390
Reputation: 86
Since you're using the "equals" predicate, your request will need to match exactly what was specified. In this case, you'll also need to add the '/' character to the end of the path. Note that you will also need to make sure you are always passing the Content-Type header in each request, otherwise the stub will not respond.
To get the behaviour you are looking for, I believe your predicate will need to look like this (no changes other than the value of 'path'):
"predicates": [
{
"equals": {
"path": "/entities/",
"query": {
"key":"first"
},
"method": "GET",
"headers": {
"Content-Type": "application/json"
}
}
}
]
Upvotes: 1