I am using spring web-flux webclient and i am passing b as null, but replaceQueryParam is still adding b param in uri. Not sure if i am doing something wrong or is there any bug.
public List<Response> getPermissions(String a, String b, String c) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path(tenantInformationProvider.getRawTenant() + "/a/b")
.queryParam("a",a).replaceQueryParam("b", b)
.replaceQueryParam("c", c).build())
.header("Authorization", "Bearer " + userInformationProvider.getToken()).retrieve()
.onStatus(HttpStatus::is4xxClientError, res -> Mono.error(new Exception("4XX received from API")))
.onStatus(HttpStatus::is5xxServerError, res -> Mono.error(new Exception("Internal server occured")))
.bodyToMono(new ParameterizedTypeReference<List<Response>>() {
}).log().block();
}
replaceQueryParam(String name, Object... values)
passing null to varargs argument still treating as not null and ultimately adding that param in URI. How can i ignore the param if its value is null?
Comment From: sbrannen
You have to use replaceQueryParam("b") instead of replaceQueryParam("b", null).
So you'll have to perform that within an if-block to check if the value of b is null.
For further assistance, please use Stack Overflow since we use this issue tracker for bugs and feature requests.