Hi, With standalone jar, I have to mock the API UR...
# general
n
Hi, With standalone jar, I have to mock the API URI that contain the query parameters with square brackets. Example : my-service/api/v1/customers?filter[profile-id]=101101 In my json file I have tried urlPath with queryParameters, urlPattern combination but it is not working because of the square bracket. It works if the query parameter does not have square bracket. Pls guide how to make the square bracket work in the query parameter?
o
Most likely the symbol is not escaped correctly. Could you please share your JSON?
n
Copy code
{
  "mappings": [
    {
      "id": "1d8c466d-c789-4583-8042-da0b44c27331",
      "request": {
        "urlPattern": "/api/mytest\\?filter=([a-z 0-9]*)",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "body": "{{ request.query.filter }}",
        "transformers": [
          "response-template"
        ]
      },
      "uuid": "1d8c466d-c789-4583-8042-da0b44c27331"
    },
    {
      "id": "cfbc81f1-af4b-45c9-9dab-c99b82437b90",
      "request": {
        "urlPattern": "/api/customer\\?filter[profile-id]=([a-z 0-9]*)",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "body": "{{ request.query.filter[profile-id] }}",
        "transformers": [
          "response-template"
        ]
      },
      "uuid": "cfbc81f1-af4b-45c9-9dab-c99b82437b90"
    }
  ],
  "meta": {
    "total": 2
  }
}
These are two mappings.
Copy code
Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
GET                                                        | GET
[regex] /api/mytest\?filter=([a-z 0-9]*)                   | /api/customer?filter[profile-id]=cab101             <<<<< URL does not match. When using a regex, "?" should be "\\?"
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------
I get this error when I run http://localhost:8080/api/customer?filter[profile-id]=cab101
o
So the issue is definitely with escaping "\\?" Is right for a single conversion, but there might be additional processing in your case, and hence you might need "\\\\?" In the input configuration. How do you pass the configuration file?
n
I keep the json files in the mapping folder
What do I need to change?
Two json files from mapping folder
o
Hm, I really need to reproduce it
n
that will be great help. Seems very simple but I am stuck
o
Will do once I get back to the computer
In progress
Hi @Naveen Purswani01. My apologies for the delay. I spent some extra time sitting up the build environment on my laptop, but I didn't forget that I want to reproduce this issue
👍 1
n
Any update on this
o
I wasn't able to reproduce, for me double backslash works on both windows and wsl2. Could you please let me know which system and version of WireMock you run?