I am using below code snippet to re-produce this issue.
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
String value= "2+3 4";
String key = "val";
queryParams.add(key, value);
ResponseSpec response = agent.get(headers->{}, queryParams, "/data/read");
String responseBody = respnose.bodyToMono(String.class).block();
The service call to producer application is happening successfully but it returns 404-Not Found since the query parameter is not encoded completely.
Encoded final url: /data/read?val=2+3%204
Expected encoded URL: /data/read?val=2%2B3%204
Here "+"
is not encoded. Appreciate any suggestion here.
Thanks, Vikram.N
Comment From: rstoyanchev
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.
Comment From: rstoyanchev
There is no way to know what serviceCaller.callGet
does exactly. Most likely the query param value needs to be expanded as a URI variable to apply the stricter encoding. Please review https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#web-uri-encoding.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: VikramAdh
Found the answers by similar issues. So closing this issue. Thank you for responses.
Comment From: diegocastro
Please post the answer so others with a similar problem can benefit from this issue.
Comment From: cah-bindiyasameem
Our team solved this issue with the help of this stack-overflow
webClient.get()
.uri { uriBuilder ->
val queryParams = mapOf(
"phone-number" to "+33612345678",
"mobile-number" to "+61432111222"
)
uriBuilder.path("/endpoint")
.apply {
queryParams.keys.forEach { key ->
queryParam(key, "{$key}")
}
}
.build(queryParams)
}