Send Map of query parameters to Spring uriBuilder

4.1k Views Asked by At

I can't find how to pass a Map of query parameters to uriBuilder even with a method found on Google which explains that we need to pass a LinkedMultiValueMap.

This is my method :

public <T> Mono<T> get(String uri, LinkedMultiValueMap params) {
        return this.webClient
                .get()
                .uri(builder -> builder
                        .path(uri)
                        .queryParam(params)
                        .build())
                .retrieve()
                .bodyToMono(new ParameterizedTypeReference<T>() {
       });
}

But I always have the following error :

queryParam (java.lang.String, Object...) in UriBuilder cannot be applied to (org.springframework.util.LinkedMultiValueMap)

It's probably really simple but I can't figured it out :/

Thanks for your help.

UPDATE :

Finally found the solution a few minutes after sending my request here ! In order to use a map for queryParam I must use .queryParams instead of .queryParam ^^

0

There are 0 best solutions below