Using Apache camel, I have Rest component. It looks like:
<post uri="/body" method="POST">
<description>Here is post method</description>
<param name="save" type="body" dataType="string"/>
<route>
<process ref="postRedirectProcessor" />
<to uri="direct:commonRoute" />
</route>
</post>
And this endpoint processes fine requests like this:
curl -i --data "b=hereisbody" http://localhost:8080/body (works fine, but I don't need it)
(I can see it goes into postRedirectProcessor and that is fine). But this is not what I want. I want it to process requests like this:
curl -i --data "hereisbody" http://localhost:8080/body (doesn't work, causes 405)
I mean, format of "data" is not like k=v&k2=v2, but it is just string, like in example (such as --data "something").
It causes an exception, it doesn't go into postRedirectProcessor.
2020-04-10 18:43:09,716 ERROR [http-nio-8080-exec-6] - ,,, - Servlet.service() for servlet [CamelServlet] in context with path [] threw exception
java.lang.IllegalArgumentException: Invalid parameter, expected to be a pair but was hereisbody
at org.apache.camel.http.common.DefaultHttpBinding.readFormUrlEncodedBody(DefaultHttpBinding.java:272) ~[camel-http-common-2.24.3.jar:2.24.3]
at org.apache.camel.http.common.DefaultHttpBinding.readRequest(DefaultHttpBinding.java:116) ~[camel-http-common-2.24.3.jar:2.24.3]
at org.apache.camel.http.common.HttpMessage.<init>(HttpMessage.java:56) ~[camel-http-common-2.24.3.jar:2.24.3]
at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:187) ~[camel-http-common-2.24.3.jar:2.24.3]
at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:79) ~[camel-http-common-2.24.3.jar:2.24.3]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
I thought, param type="body" as in xml posted, does the trick, but no luck.