This message was deleted.
# help
s
This message was deleted.
b
Hi @Preethu Kg, I think there are two ways to solve this. 1. using custom matching logic (see https://wiremock.org/docs/extending-wiremock/ under 'Custom Request Matchers)
p
Okay @Bas Dijkstra. But is there any other way to parse the incoming date and check whether its today's date
b
Yes, that was option 2. I was just writing you an example. Something like this should work, too (although I didn't test it yet)
Copy code
stubFor(post(urlEqualTo("/someUrl"))
                .withRequestBody(
                        matchingJsonPath("$.date", equalToDateTime(LocalDateTime.now()).actualFormat("yyyy/MM/dd"))
                )
                .willReturn(aResponse()
                        .withStatus(200))
        );
Just substitute your own JsonPath and datetime format
More examples at https://wiremock.org/docs/request-matching/ under 'Dates and times'. Examples in the docs are for headers but work for body elements, too.
p
Actually I had tried it with actualDateFromat as well. But it was not picking up
@Bas Dijkstra Adding one more query. For eg, I need to parse a date from my input request and use the same in response but different format Parameterization used in response json is as below : endDate :[ "{{date (parseDate jsonPath request.body '$.endDate') format ='yyyy-MM-dd'}}T190000.00Z" And I am getting below exception:
b
That's a good one, I don't know, it's been a while since I've had to do that, and I don't really use JSON definitions a lot either