How to tell wiremock to ignore query strings parameters in mapping file

8,345 views
Skip to first unread message

Ricardo Mayerhofer

unread,
Jun 7, 2015, 11:24:19 AM6/7/15
to wiremo...@googlegroups.com
Hello all!
Currently I have the following configuration file in my mapping folder:

{
    "request": {
        "method": "GET",
        "url": "/myurl"
    },
    "response": {
        "status": 200,
        "bodyFileName": "contacts.json"
    }
}

What I'm facing is that any query parameter appended in the request URL breaks my mock, so a call to http://mockurl/myurl?query=string gives me a 404.

Is there a way to tell wiremock to ignore query parameters when mapping mock URLs?

Thanks.

Tom Akehurst

unread,
Jun 7, 2015, 11:35:16 AM6/7/15
to wiremo...@googlegroups.com, ricar...@gmail.com
Easiest way is probably to use a regex:
"urlPattern":"/myurl\?.*"

Ricardo Mayerhofer

unread,
Jun 13, 2015, 6:23:19 PM6/13/15
to wiremo...@googlegroups.com, ricar...@gmail.com
Works like charm. Thanks Tom. 
Reply all
Reply to author
Forward
0 new messages