Camel HTTP End point Special Charcter(+) issue

295 Views Asked by At

I am having issues hitting an http end point via camel recipientlist(2.14).

<route id="httpexecutor">
        <from uri="direct:httpexecutor" />
        <process ref="httpPreprocessor" />
        <recipientList>
            <simple>${property[inputSearchParameter.url]}</simple>
        </recipientList>
</route>

When the url has a + sign(in one of the parameters) then its breaking. I also tried %2B then it is getting converted to space.

There is a JIRA: https://issues.apache.org/jira/browse/CAMEL-6176

However when i am using RAW its not working and getting the following trace(seems like RAW is passed to the service):

Caused by: java.net.URISyntaxException: Illegal character in query at index 558: http://someurl?facet=true&binary=true&-fq=nm_task_type%3A%28OTM_QUERY+OR+OTM_CLIENT_QUERY%29&facet.query=%7B%21key%3D%22%5B*+TO+NOW-30%5D%22%7Ddt_created%3A%5B*+TO+NOW-30DAY%5D&facet.query=%7B%21key%3D%22%5BNOW-30DAY+TO+NOW-15DAY%5D%22%7Ddt_created%3A%5BNOW-30DAY+TO+NOW-15DAY%5D&facet.query=%7B%21key%3D%22%5BNOW-15DAY+TO+NOW-7DAY%5D%22%7Ddt_created%3A%5BNOW-15DAY+TO+NOW-7DAY%5D&facet.query=%7B%21key%3D%22%5BNOW-7DAY+TO+NOW-1DAY%5D%22%7Ddt_created%3A%5BNOW-7DAY+TO+NOW-1DAY%5D&facet.query=RAW({!key="[NOW-1DAY TO NOW]"}dt_created:[NOW-1DAY TO NOW+1DAY])&q=*%3A*&rows=0
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
    at java.net.URI$Parser.parseHierarchical(URI.java:3092)
    at java.net.URI$Parser.parse(URI.java:3034)
    at java.net.URI.<init>(URI.java:595)
    at org.apache.camel.util.URISupport.createURIWithQuery(URISupport.java:334)
    at org.apache.camel.util.URISupport.createRemainingURI(URISupport.java:428)
    at org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:248)
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:122)
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:525)
    ... 52 more

Any help appeciated.

1

There are 1 best solutions below

0
On

I haven't tested this, but can you set header "CamelHttpPath" to your URL before passing to Camel HTTP component and see if it helps:

<setHeader headerName="CamelHttpPath">
  <simple>YOUR_URL</simple>
</setHeader>