Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiremock not detecting POST body request by Spring 6 RestClient #2623

Open
rana2884 opened this issue Mar 2, 2024 · 1 comment
Open

Wiremock not detecting POST body request by Spring 6 RestClient #2623

rana2884 opened this issue Mar 2, 2024 · 1 comment
Labels

Comments

@rana2884
Copy link

rana2884 commented Mar 2, 2024

Proposal

I am trying to use Wiremock to test RestClient requests released recently in Spring 6.1. I am facing issue only in the case of restClient making POST request with body which wiremock fails to detect showing message "body does not exist" so not able to mock the expected response to the request. E.g.

restClient
                .post()
                .uri("/todos")
                .contentType(MediaType.APPLICATION_JSON)
                .body(panResponse)
                .retrieve()
                .body(String.class);

Wiremock stub:

wireMockServer.stubFor(
                WireMock.post("/todos")
                        .withHeader("Content-type", equalTo("application/json"))
                        .withRequestBody(
                                equalToJson(objectMapper.writeValueAsString(panResonse)))
                        .willReturn(WireMock.aResponse().withStatus(200).withBody("Hello")));

Reproduction steps

Make a POST request with request body with RestClient and try to mock it with wiremock, it will show message "Body does not exist."

References

No response

@rana2884 rana2884 added the bug label Mar 2, 2024
@wimdeblauwe
Copy link

Not sure if it is related, but I also filed an issue that uses RestClient: #2637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants