https://linen.dev logo
#help
Title
# help
t

Tapan Gujjar

08/21/2023, 6:55 PM
Hi I am trying to mock a request using logical operator using wiremock
v2.27.2
. The request is as below:
Copy code
{
  "request": {
    "method": "POST",
    "urlPattern": "sampleRequest",
    "headers": {
      "Authorization": {
        "matches": "\\btestStandardAuthCode(Warn)?\\b"
      }
    },
    "bodyPatterns": [
      {
        "matchesJsonPath": {
          "expression": "$.date",
          "and": [
            {
              "before": "2022-01-01T00:00:00"
            },
            {
              "after": "2020-01-01T00:00:00"
            }
          ]
        }
      }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "body/sampleresponse.json"
  }
}
However when I running it, I am getting the below error
Copy code
com.github.tomakehurst.wiremock.standalone.MappingFileException:
{"expression":"$.date","and":[{"before":"2022-01-01T00:00:00"},{"after":"2020-01-01T00:00:00"}]} is not a valid match operation
t

Tom

08/21/2023, 8:03 PM
Logical AND and OR weren’t introduced until much later. I suggest upgrading to 2.35.0 at least, or better still 3.0.0-beta-15.