https://linen.dev logo
#help
Title
# help
c

Callum Johnson

04/26/2023, 10:40 AM
Hi, Does anyone have a reply to my previous message please: Hey everyone, I am trying to use the JsonPathMatcher but don't seem to be getting any success. I am using wiremock.net nuget in a .NET6 project. this is the code I have: This is my request: { "person": { "forename": "Test", "surname": "APPLE" } } server.Given(Request.Create().WithPath(_urlPath).WithHeader("content-type", "application/json").UsingPost().WithBody(new JsonPathMatcher("$.person.surname == 'APPLE'"))).RespondWith(Response.Create().WithStatusCode(200).WithHeader("content-type", "application/json;charset=UTF-8").WithBodyAsJson(new FileInfo("ResponseFiles/Apple.json").FullName)); I have tried using the following variations: new JsonPathMatcher("[?(@.surname == 'APPLE')]") new JsonPathMatcher("person.surname == 'APPLE')]") Any help would be greatly appreciated 🙂
o

Oleg Nenashev

04/26/2023, 11:18 AM
Sorry, it went missing. I will ask the WireMock.NET maintainer whether he'd like to join
BTW, their official chat is here: https://gitter.im/wiremock_dotnet/Lobby . Maybe makes sense to ask there right away while I fuger out the community side
b

Bas Dijkstra

04/26/2023, 3:00 PM
I’ve worked with WireMock .Net quite a bit myself. I use it to write acceptance tests for RestAssured .Net (shameless plug!), for example, and I share your views. I’ve had more luck with the JmesPathMatcher: https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#jmes-path-jmespathmatcher
c

Callum Johnson

04/26/2023, 3:16 PM
Hey, Thank you for the replies, It's greatly appreciated. I will join the Lobby and see if there is a solution. Also, I will take a look at the JmesPathMatcher. :-)
b

Bas Dijkstra

04/27/2023, 8:53 AM
If you’re looking for an example, I’ve got a working one with a test that invokes the matcher right here in my WireMock .Net workshop: https://github.com/basdijkstra/wiremock-net-workshop/blob/39cdf4b52f2dc6ba2dbca5d8cda1ea280cb84a11/WireMockNetWorkshop/Answers/Answers02.cs#L89
👍 1
2 Views