Recently i met a weird exception when using a Rest API endpoint provided by Red Hat Fuse (or Apache Camel) and deployed on top of Spring Boot,
javax.servlet.ServletException: java.lang.IllegalArgumentException: Invalid characters (CR/LF) in header message at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:235) ~[camel-http-common-2.21.0.fuse-770013-redhat-00001.jar!/:2.21.0.fuse-770013-redhat-00001] at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:80) ~[camel-http-common-2.21.0.fuse-770013-redhat-00001.jar!/:2.21.0.fuse-770013-redhat-00001] at javax.servlet.http.HttpServlet.service(HttpServlet.java:791) ~[jboss-servlet-api_4.0_spec-1.0.0.Final.jar!/:1.0.0.Final] at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) ~[undertow-servlet-2.0.30.SP1-redhat-00001.jar!/:2.0.30.SP1-redhat-00001] at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) ~[undertow-servlet-2.0.30.SP1-redhat-00001.jar!/:2.0.30.SP1-redhat-00001]
It happens everytime im using below CURL command,
curl -kv -L -X POST https://url/api/ -H 'Authorization: Basic Yxxxx' -H 'Content-Type: application/json'
--data-raw '{
"id": "123",
"birthDate": "19900429"
}'
The funny thing is, i think culprit is because i have a newline within my json body request. After i change my command into below CURL, it seems that everything is working well now.
curl -kv -L -X POST https://url/api/ -H 'Authorization: Basic Yxxxx' -H 'Content-Type: application/json'
--data-raw '{"id": "123","birthDate": "19900429"}'
Weird eh