WireMock.Net icon indicating copy to clipboard operation
WireMock.Net copied to clipboard

Matching for x-www-form-urlencoded request body

Open KyryloAntoshyn opened this issue 2 years ago • 1 comments

Hi!

I need to mock POST request with x-www-form-urlencoded body: param1=value1&param2=value2&param3=value3&param4=value4. I've been reading wiki pages regarding request matching but haven't found any option for matching URL encoded body. Is it possible to achieve with WireMock.Net. If yes, how can I implement it?

Thanks in advance!

KyryloAntoshyn avatar Aug 09 '22 18:08 KyryloAntoshyn

@KyryloAntoshyn Did you just try this:

For the body:

"Body": {
            "Matcher": {
                "Name": "ExactMatcher",
                "Pattern": "param1=value1&param2=value2&param3=value3&param4=value4"
            }
        }

And for the header:

"Headers": [
      {
        "Name": "Content-Type",
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "x-www-form-urlencoded",
            "IgnoreCase": true
          }
        ]
      }
    ]

StefH avatar Aug 10 '22 06:08 StefH

Thanks, it works fine for me!

KyryloAntoshyn avatar Aug 10 '22 08:08 KyryloAntoshyn