I'm using a WebClient in a Spring Reactive application and need to make several calls as part of the steps the publisher goes through.

I wanted to do the following:

public Mono<ResponsePojo> getHistoricProcessInstances(Mono<String> uriParameter) {
    return webClient
                .get()
                .uri("foo?bar={uriParameter}",
                        Map.of("uriParameter", uriParameter))
                .retrieve()
                .bodyToMono(ResponsePojo.class);
}

I had to do the following instead as a workaround:

public Mono<ResponsePojo> getHistoricProcessInstances(Mono<RequestPojo> request) {
    return webClient
                .post()
                .uri("foo")
                .body(RequestPojo, RequestPojo.class)
                .retrieve()
                .bodyToMono(ResponsePojo.class);
}

I was lucky that the API I was calling supported the same parameters in the body as a post, but that's not always the case.

Are there plans to support this or is a reactive pattern for a workaround?

Comment From: rstoyanchev

No, there are no plans to accept async parameters for building the URI. I would resolve the parameter and then make the call with the resolved value:

uriParameter.flatMap(p ->
    webClient
        .get()
        .uri("foo?bar={uriParameter}", Map.of("uriParameter", p))
        .retrieve()
        .bodyToMono(ResponsePojo.class));

For multiple parameters you can use .zip(...).

Comment From: sshevlyagin

Thanks, I appreciate the response and suggestion.