<!here>, Good Morning/Good Evening, In my server r...
# general
r
<!here>, Good Morning/Good Evening, In my server request API is taking client CTA clicked time in one of the key of body data, which is resulting body mismatch error on mocked mappings, since I am not able to pass actual end user's time in mapping. How can I handle this?
r
Assuming you are trying to match JSON, you could use json-unit to match that part of the body. See https://github.com/lukas-krecan/JsonUnit#typeplc and https://wiremock.org/docs/request-matching/
Alternatively you could match on a more specific bit of the body using
matchingJsonPath
instead of trying to match the whole body. Again there are details here: https://wiremock.org/docs/request-matching/
r
Thanks for the quick and valuable response, actually I am trying to mock the mapping with the actual client request time
r
I don't think I understand what it is you are trying to achieve
r
OK! let me put in another way. In wiremock recording let's suppose field A is having value
Mon Mar 06 05:00:45 GMT-04:00 2023
But as it is taking current client request time, while play back in request it is taking A's value as
Tue Mar 07 10:49:03 GMT-04:00 2023
in body request. Which is resulting body mismatch and my playback execution is getting failed
r
I'm not sure what you are hoping for? If you know what the value in the request will be then you can set the stub mapping's expected body to be that value and it will match. If you don't know what the value in the request will be then you can set the stub mapping's expected body to have a
json-unit
expression so that it will match despite having an unknown value. But you seem to want to match a specific time without being able to control what time the client sends?
r
yes
r
I can't imagine how that could ever be possible?
You would have to control the clock in the client. That's probably possible, but it's nothing to do with WireMock.
r
OK