Reputation: 357
In order to have my Java SpringBoot application integrated with a regular REST endpoint, I have this method to prepare the URI
import org.springframework.web.util.UriComponentsBuilder;
private URI prepareEndpointUrl(MyQuery q) {
return UriComponentsBuilder.fromHttpUrl(apiConfiguration.getLeadTimesPreCalcRestEndpointUrl())
.queryParam(PARAM1, q.getCountryFrom())
.queryParam(PARAM2, q.getZipCodeFrom())
.queryParam(PARAM3, q.getCountryTo())
.queryParam(PARAM4, q.getZipCodeTo())
.build().toUri();
}
The URL is being passed by parameter to UriComponentsBuilder as a first argument depends on which environment my application is running.
Works perfectly for all lower environments, but in prod is throwing a java.lang.IllegalArgumentException.
ERROR @ o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: [ https://A_VALID_HOST/api/XX-YY.json] is not a valid HTTP URL] with root cause
java.lang.IllegalArgumentException: [ https://A_VALID_HOST/api/XX-YY.json] is not a valid HTTP URL
I google this, and apparently it could be related with encoding the url/parameters, whch I am not doing. Apparentrly something is different in this env, and I have not idea how to start finding what.
any idea?
Upvotes: 0
Views: 2276
Reputation: 357
As marked by Stephen above, the problem was a blank space in my URL, before http.
Apparently, is not trimmed; thanks everyone.
Upvotes: 2