I am trying to build rest api using camel-rest-dsl. I have tried with multiple provider, spark-rest, jetty. But it throwing marshelling exception when i use RestBindingMode.json, if i remove rest binding mode then it works fine with string type.
I am using version 2.22.1 *SpringRouteBuilder* *--------------------------* @Component public class RestAPIRoutes extends SpringRouteBuilder { @Override public void configure() throws Exception { restConfiguration().component("spark-rest") .bindingMode(RestBindingMode.json) .port(8787) .dataFormatProperty("prettyPrint","true"); rest("/balance").produces("application/json").consumes("application/json") /* mock api */ .get("/query").route().bean(BalanceService.class,"fetchBalance").endRest() /* fetch balance by msisdn*/ .get("/query/{msisdn}").description("Fetch line balance by msisdn") .type(BalanceInfo.class).to("bean:balanceService?method=fetchBalance(${header.msisdn})") .post("/update").type(BalanceInfo.class).outType(BalanceInfo.class).to("bean:balanceService?method=updateBalance"); } } Here balanceService is a simple Spring @Service with overloaded method and BalanceInfo is simple pojo class with two field and getter setters. *Pom dependency* <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spark-rest</artifactId> <version>2.22.1</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spring-boot-starter</artifactId> <version>2.22.1</version> </dependency> *Exception* org.apache.camel.processor.binding.BindingException: Cannot bind to json as message body is not json compatible. Exchange[ID-LTB0202777-MAC-1540301942376-3-1] at org.apache.camel.processor.RestBindingAdvice.unmarshal(RestBindingAdvice.java:317) ~[camel-core-2.22.1.jar:2.22.1] at org.apache.camel.processor.RestBindingAdvice.before(RestBindingAdvice.java:137) ~[camel-core-2.22.1.jar:2.22.1] Please help Rahul