JsonMatcher does not match a body containing an array of strings #234

Closed
opened 2025-12-29 08:24:30 +01:00 by adam · 4 comments
Owner

Originally created by @mhartigh on GitHub (Dec 12, 2019).

Hi,

This scenario did work on version 1.32 but since 1.33 the mapping does not match anymore. I have also tried version 1.40 but no difference. Am I supposed to apply a different approach?

We have the following mapping:


    "Guid": "1a48bb7d-c073-4b1c-85a8-09d4409a6e57",
    "Priority": 10,
    "Request": {
      "Path": {
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "/Events/Annuleren",
            "IgnoreCase": true
          }
        ]
      },
      "Methods": [
        "POST"
      ],
      "Body": {
        "Matcher": {
          "Name": "JsonMatcher",
          "Pattern": "[\"0455baac-37d8-4a5e-9240-d2af254c7e66\",\"0455baac-37d8-4a5e-9240-d2af254c7e70\"]",
          "IgnoreCase": true
        }
      }
    },
    "Response": {
      "StatusCode": 200,
      "Headers": {}
    }

The following request does not match:


    "Guid": "dcd35ec5-13c3-4908-8822-b8c04a09b548",
    "Request": {
      "ClientIP": "xx.xx.xx.xx",
      "DateTime": "2019-12-12T09:41:49.7304608Z",
      "Path": "/Events/Annuleren",
      "AbsolutePath": "/Events/Annuleren",
      "Url": "http://localhost:10862/Events/Annuleren",
      "AbsoluteUrl": "http://localhost:10862/Events/Annuleren",
      "Query": {},
      "Method": "POST",
      "Headers": {
        "Connection": [
          "keep-alive"
        ],
        "Content-Type": [
          "text/plain"
        ],
        "Accept": [
          "*/*"
        ],
        "Accept-Encoding": [
          "gzip, deflate"
        ],
        "Host": [
          "localhost:10862"
        ],
        "User-Agent": [
          "PostmanRuntime/7.11.0"
        ],
        "Content-Length": [
          "79"
        ]
      },
      "Body": "[\"0455baac-37d8-4a5e-9240-d2af254c7e66\",\"0455baac-37d8-4a5e-9240-d2af254c7e70\"]",
      "BodyAsJson": [
        "0455baac-37d8-4a5e-9240-d2af254c7e66",
        "0455baac-37d8-4a5e-9240-d2af254c7e70"
      ],
      "BodyEncoding": {
        "CodePage": 65001,
        "EncodingName": "Unicode (UTF-8)",
        "WebName": "utf-8"
      },
      "DetectedBodyType": "Json",
      "DetectedBodyTypeFromContentType": "String"
    },
    "Response": {
      "StatusCode": 404,
      "Headers": {
        "Content-Type": [
          "application/json"
        ]
      },
      "BodyAsJson": {
        "Status": "No matching mapping found"
      },
      "DetectedBodyType": 2,
      "DetectedBodyTypeFromContentType": 0
    }

Thanks for your help!

Originally created by @mhartigh on GitHub (Dec 12, 2019). Hi, This scenario did work on version 1.32 but since 1.33 the mapping does not match anymore. I have also tried version 1.40 but no difference. Am I supposed to apply a different approach? We have the following mapping: ``` c# "Guid": "1a48bb7d-c073-4b1c-85a8-09d4409a6e57", "Priority": 10, "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/Events/Annuleren", "IgnoreCase": true } ] }, "Methods": [ "POST" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "[\"0455baac-37d8-4a5e-9240-d2af254c7e66\",\"0455baac-37d8-4a5e-9240-d2af254c7e70\"]", "IgnoreCase": true } } }, "Response": { "StatusCode": 200, "Headers": {} } ``` The following request does not match: ``` c# "Guid": "dcd35ec5-13c3-4908-8822-b8c04a09b548", "Request": { "ClientIP": "xx.xx.xx.xx", "DateTime": "2019-12-12T09:41:49.7304608Z", "Path": "/Events/Annuleren", "AbsolutePath": "/Events/Annuleren", "Url": "http://localhost:10862/Events/Annuleren", "AbsoluteUrl": "http://localhost:10862/Events/Annuleren", "Query": {}, "Method": "POST", "Headers": { "Connection": [ "keep-alive" ], "Content-Type": [ "text/plain" ], "Accept": [ "*/*" ], "Accept-Encoding": [ "gzip, deflate" ], "Host": [ "localhost:10862" ], "User-Agent": [ "PostmanRuntime/7.11.0" ], "Content-Length": [ "79" ] }, "Body": "[\"0455baac-37d8-4a5e-9240-d2af254c7e66\",\"0455baac-37d8-4a5e-9240-d2af254c7e70\"]", "BodyAsJson": [ "0455baac-37d8-4a5e-9240-d2af254c7e66", "0455baac-37d8-4a5e-9240-d2af254c7e70" ], "BodyEncoding": { "CodePage": 65001, "EncodingName": "Unicode (UTF-8)", "WebName": "utf-8" }, "DetectedBodyType": "Json", "DetectedBodyTypeFromContentType": "String" }, "Response": { "StatusCode": 404, "Headers": { "Content-Type": [ "application/json" ] }, "BodyAsJson": { "Status": "No matching mapping found" }, "DetectedBodyType": 2, "DetectedBodyTypeFromContentType": 0 } ``` Thanks for your help!
adam added the bug label 2025-12-29 08:24:30 +01:00
adam closed this issue 2025-12-29 08:24:30 +01:00
Author
Owner

@StefH commented on GitHub (Dec 12, 2019):

This behavior was changed since 1.0.33 and I did not test this specific scenario.
I will take a look at the code.

@StefH commented on GitHub (Dec 12, 2019): This behavior was changed since 1.0.33 and I did not test this specific scenario. I will take a look at the code.
Author
Owner

@StefH commented on GitHub (Dec 12, 2019):

@mhartigh Can you please try this version (WireMock.Net.1.0.40-ci-12333) from MyGet.

@StefH commented on GitHub (Dec 12, 2019): @mhartigh Can you please try this version (`WireMock.Net.1.0.40-ci-12333`) from MyGet.
Author
Owner

@mhartigh commented on GitHub (Dec 13, 2019):

@mhartigh Can you please try this version (WireMock.Net.1.0.40-ci-12333) from MyGet.

HI Stef,

Thank you! This version does work properly!

Regards

@mhartigh commented on GitHub (Dec 13, 2019): > > > @mhartigh Can you please try this version (`WireMock.Net.1.0.40-ci-12333`) from MyGet. HI Stef, Thank you! This version does work properly! Regards
Author
Owner

@StefH commented on GitHub (Dec 13, 2019):

OK, I'll create a new official NuGet tomorrow.

@StefH commented on GitHub (Dec 13, 2019): OK, I'll create a new official NuGet tomorrow.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#234