We are trying to use Apache Camel
2.16.3 to push some data to a third-party HTTP
endpoint. We are using HTTP4
Component. We are setting the uri, method and query params as headers in the message. However, the endpoint contains an underscore (_
) and we are getting an exception like this:
Caused by: java.lang.IllegalArgumentException: Invalid uri: https://x_y.something.com/somePath?q_one=XXXX&q_two=YYYYY. If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: Endpoint[https4://placeholder?throwExceptionOnFailure=false]
I have been researching a bit and it looks like that _
is something that should not be there in the URI. This website actually says that https://x_y.something.com/somePath
is invalid but https://xy.something.com/somePath
is valid.
Since I cannot change the third-party endpoint, is it possible to escape the underscore somehow? If not, is there any other solution or we need to abandon Apache Camel
for this?
EDIT
Without seeing a code example I cannot be sure what the root cause is, but if I understand correctly, you are sending an HTTP request to an akka actor which is consuming from a Camel endpoint. My guess is that you're probably not populating the headers correctly - regardless of what the original HTTP4
endpoint looks like, Exchange.HTTP_URI
header override will always take precedence. For example, this works perfectly fine:
from("jetty:http://localhost:9090/path")
.routeId("jetty_server")
.log("${body}");
from("timer:sender?delay=3000&period=5000")
.setBody().constant("Ping!")
.setHeader(Exchange.HTTP_URI, constant("http://localhost:9090/path"))
.to("http4:x_y.something.com:9090/path?q_one=XXXX&q_two=YYYYY");
So my guess is that it's not a Camel issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With