I have the following wiremock JSON mapping ```{ ...
# help
j
I have the following wiremock JSON mapping
Copy code
{
  "mappings": [
    {
      "name": "get-credit-report-fail",
      "request": {
        "method": "GET",
        "urlPathPattern": "/pvt/v1/bureau/pan-number",
        "queryParameters": {
          "uuid": {
            "matches": ".*crs-fail"
          }
        }
      },
      "response": {
        "status": 500
      }
    },
    {
      "name": "get-credit-report-success",
      "request": {
        "method": "GET",
        "urlPathPattern": "/pvt/v1/bureau/pan-number"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "success": true,
          "data": {
            "panNumber": "ABCDE1234F",
            "vendor": "EQUIFAX"
          },
          "status_code": 200
        }
      }
    }
  ]
}
When I try to match it with curl
Copy code
curl --location 'localhost:8080/pvt/v1/bureau/pan-number?uuid=crs-fail'
it gives the below response
Copy code
{
  "success": true,
  "data": {
    "panNumber": "ABCDE1234F",
    "vendor": "EQUIFAX"
  },
  "status_code": 200
}
instead of 500 error
l
Hi. Would the following work for you:
Copy code
{
  "mappings": [
    {
      "name": "get-credit-report-fail",
      "request": {
        "method": "GET",
        "urlPattern": "/pvt/v1/bureau/pan-number\\?uuid=.*crs-fail"
      },
      "response": {
        "status": 500
      }
    },
    {
      "name": "get-credit-report-success",
      "request": {
        "method": "GET",
        "url": "/pvt/v1/bureau/pan-number"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "success": true,
          "data": {
            "panNumber": "ABCDE1234F",
            "vendor": "EQUIFAX"
          },
          "status_code": 200
        }
      }
    }
  ]
}
j
No I want to use queryParams. Not path. Also it worked for me by changing the order of "get-credit-report-fail", and "get-credit-report-success
l
Glad you got it working. The example I gave still uses the uuid parameter as a query parameter on the request not a path parameter. Doing it that way also meant you wouldn’t have to worry about the order of the mappings in the file.
j
ohh right. got it. thank you!
đź‘Ť 1