Matching for x-www-form-urlencoded request body #435

Closed
opened 2025-12-29 15:23:42 +01:00 by adam · 2 comments
Owner

Originally created by @KyryloAntoshyn on GitHub (Aug 9, 2022).

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!

Originally created by @KyryloAntoshyn on GitHub (Aug 9, 2022). 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!
adam added the question label 2025-12-29 15:23:42 +01:00
adam closed this issue 2025-12-29 15:23:42 +01:00
Author
Owner

@StefH commented on GitHub (Aug 10, 2022):

@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 commented on GitHub (Aug 10, 2022): @KyryloAntoshyn Did you just try this: For the body: ``` json "Body": { "Matcher": { "Name": "ExactMatcher", "Pattern": "param1=value1&param2=value2&param3=value3&param4=value4" } } ``` And for the header: ``` json "Headers": [ { "Name": "Content-Type", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "x-www-form-urlencoded", "IgnoreCase": true } ] } ] ```
Author
Owner

@KyryloAntoshyn commented on GitHub (Aug 10, 2022):

Thanks, it works fine for me!

@KyryloAntoshyn commented on GitHub (Aug 10, 2022): Thanks, it works fine for me!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#435