mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
ParamMatcher failed when using parameter with comma #467
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @geovanegodoi on GitHub (Nov 24, 2022).
Originally assigned to: @StefH on GitHub.
Describe the bug
I'm working on a system that consumes a 3rd party API which accepts as querystring a SQL statement.
For example, to query some data from any table just build the URI like this:
http://host/api/queryservice?query=SELECT id FROM table WHERE id = 1While trying to mock this API, I realized that whenever I tried to mock a statement using comma, the ParamMatcher fails.
For example,
SELECT id, value FROM table WHERE id = 1.And I received a 404 (NotFound) error code.
Expected behavior:
I expected the ParamMatcher has succeded, and returned 200 (OK).
Test to reproduce
1 - Create an API which receives as querystring a SQL statement
2 - Mock that API using "WithParam" function
3 - Test creating a statement which has a 'comma' within, "SELECT id, value FROM table WHERE id = 1"
Other related info
Provide additional information if any.
@StefH commented on GitHub (Nov 24, 2022):
What you can try:
1️⃣
url-escape the comma
2️⃣
Set https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettings.cs#L267 to
QueryParameterMultipleValueSupport.NoComma@geovanegodoi commented on GitHub (Nov 24, 2022):
Thanks for reply,
I've downloaded the latest nuget version (1.5.10) but there isn't this property.
Am I doing something wrong?
@StefH commented on GitHub (Nov 24, 2022):
No. Nothing is wrong on your end
I just realized that I need to release a new version which includes this.
I'll do that now.
@geovanegodoi commented on GitHub (Nov 24, 2022):
Thanks, @StefH
I've just downloaded the new release, and now the property is ok.
When you said "url-escape the comma", could you show an example?
I tried somethings, but I still got the error.
@StefH commented on GitHub (Nov 25, 2022):
It could be that Url escaping does indeed nor work.
Then you need to use option 2.
Can this issue be closed?
@geovanegodoi commented on GitHub (Nov 25, 2022):
I'm still facing the issue.
The API I'm trying to mock is this one:
https://docs.oracle.com/en/cloud/saas/service/18a/cxsvc/op-services-rest-connect-v1.4-queryresults-get.html
It's a public Oracle REST API, to query entities from database.

When I try to mock this request I get a 404 error.
@StefH commented on GitHub (Nov 30, 2022):
https://github.com/WireMock-Net/WireMock.Net/pull/854
@StefH commented on GitHub (Nov 30, 2022):
@gigiogodoi
Can you please provide a full working c# code example which simulates your issue? Because I cannot reproduce it using unit tests.
@geovanegodoi commented on GitHub (Nov 30, 2022):
@StefH
Follow an example repository to reproduce the error, using XUnit and .NET6 .
https://github.com/gigiogodoi/UnitTestWithWiremock
Inside it, there are 2 test cases, one failing because it is using a query with comma.
@StefH commented on GitHub (Nov 30, 2022):
Thanks a lot for this unit test. I did find the issue and it's fixed in preview version
1.5.11-ci-16748.@geovanegodoi commented on GitHub (Nov 30, 2022):
@StefH
Could you add a testcase to validate a querystring like this ?
query=select id, name, value from table where id in (1, 2, 3, 4, 5)
@StefH commented on GitHub (Nov 30, 2022):
Yes.
Works fine.
https://github.com/WireMock-Net/WireMock.Net/blob/stef-849/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs
@StefH commented on GitHub (Dec 2, 2022):
@gigiogodoi Is it ok?
@StefH commented on GitHub (Dec 3, 2022):
I'll merge the PR.
@geovanegodoi commented on GitHub (Dec 3, 2022):
I was not able to download the preview version, because it was not releated in the nuget package manager.
But I will try once you release a new version.
@StefH commented on GitHub (Dec 3, 2022):
previews are here: https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
But I'll release an official version today on nuget.