Wiremock not responding for multiple queryParameters

3,719 views
Skip to first unread message

M Bilel Fitouri

unread,
Mar 16, 2016, 7:45:30 AM3/16/16
to wiremock-user
Hello,

I am having a pb when i curl the url localhost:9999/hello?begin-date=2000-01-01&end-date=2000-01-01 this mock :

{
"request": {
"method": "GET",
"urlPattern": "/hello",
"queryParameters": {
   "begin-date": {
"matches": "2000-01-01"
   },
   "end-date": {
"matches": "2000-01-01"
   }
}
},
"response": {
"status": 200,
"bodyFileName": "response.json",
"headers": {
                    "Content-Type": "application/json;charset=UTF-8"
            }
}
}

The error is :
2016-03-16 12:40:25.828 Request received:
GET /hello?begin-date=2000-01-01 HTTP/1.1
User-Agent: curl/7.36.0
Host: localhost:9999
Accept: */*


2016-03-16 12:40:25.828 No mapping found matching URL /hello?begin-date=2000-01-01
2016-03-16 12:40:25.829 Not recording mapping for /hello?begin-date=2000-01-01 as this has already been received


When i try with only one parameter, it works, it seems that wiremock does not understand a url with '&' symbol. Any idea ?

Thx

Tom Akehurst

unread,
Mar 16, 2016, 2:23:30 PM3/16/16
to wiremock-user
I suggest trying urlPath rather than urlPattern and equals rather than matches for the query params.

M Bilel Fitouri

unread,
Mar 17, 2016, 9:10:42 AM3/17/16
to wiremock-user
Thank you for your suggestion Tom, i tried this but still the same pb :

2016-03-17 14:09:20.456 URL /hello?begin-date=2000-01-01 is match, but query parameter end-date is not. For a match, value should equal 2000-01-01
2016-03-17 14:09:20.456 No mapping found matching URL /hello?begin-date=2000-01-01
2016-03-17 14:09:20.460 Not recording mapping for hello?begin-date=2000-01-01 as this has already been received

The new mock is :

{
"request": {
"method": "GET",
"urlPath": "/hello",
"queryParameters": {
   "begin-date": {
"equalTo": "2000-01-01"
   },
   "end-date": {
"equalTo": "2000-01-01"

M Bilel Fitouri

unread,
Mar 17, 2016, 9:15:49 AM3/17/16
to wiremock-user
I took a look to the code and i saw this, may be i am wrong but i found this :

(Class Jetty6HttpServletRequestAdapter)
private String withQueryStringIfPresent(String url) {
        return url + (isNullOrEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString());
    } 

That maybe explains why we dont have the full url in the error stacktrace : 

2016-03-16 12:40:25.828 No mapping found matching URL /hello?begin-date=2000-01-01
2016-03-16 12:40:25.829 Not recording mapping for /hello?begin-date=2000-01-01 as this has already been received

Tom Akehurst

unread,
Mar 17, 2016, 9:35:32 AM3/17/16
to wiremock-user

Your stub worked for me with the latest 2.x version, with this curl command:

M Bilel Fitouri

unread,
Mar 17, 2016, 12:27:18 PM3/17/16
to wiremock-user
It works !

the pb was stupid, in my curl, i didnt put the url between 2 quotes. That worked fine i have an url without '&' symbol. 

It wasnt a wiremock pb

Thx a lot Tom

Tom Akehurst

unread,
Mar 17, 2016, 12:29:50 PM3/17/16
to wiremock-user
I regularly get caught out by that one :-)
Reply all
Reply to author
Forward
0 new messages