-
-
Notifications
You must be signed in to change notification settings - Fork 209
Request Matcher FormUrlEncodedMatcher
Stef Heyenrath edited this page Jul 27, 2024
·
2 revisions
Can be used to check if a Form Url Encoded body contains the key-value pairs.
var server = WireMockServer.Start();
server.Given(
Request.Create()
.UsingPost()
.WithPath("/foo")
.WithHeader("Content-Type", "application/x-www-form-urlencoded")
.WithBody(new FormUrlEncodedMatcher(["name=John Snow", "[email protected]"]))
)
.RespondWith(
Response.Create()
);
{
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/foo"
}
]
},
"Methods": [
"POST"
],
"Headers": [
{
"Name": "Content-Type",
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "application/x-www-form-urlencoded",
"IgnoreCase": true
}
]
}
],
"Body": {
"Matcher": {
"Name": "FormUrlEncodedMatcher",
"Patterns": [
"name=John Snow",
"[email protected]"
],
"IgnoreCase": true
}
}
},
"Response": {
"StatusCode": 200
}
}
- You can also use
IgnoreCase
- And you can also use wildcards like:
name=John*
- Home
- What is WireMock.Net
- WireMock.Org
- References
- Settings
- Admin REST API
- Proxying
- Stubbing
- Webhook
- Request Matching
- Response Templating
- Unit Testing
- Using WireMock
- Advanced
- Errors