You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Wang Yan <wy...@gmail.com> on 2021/08/27 08:19:37 UTC

json to Pojo convertion problem for camel Rest DSL

Hello All,

I am using  camel RestDSL to get Json and conver it to pojo by
.post().type(Schema.class)
but i got below exception
org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value: < *srroy i need to hide package name
here* >Schema


below is the snippet of my code. i could not find any problem. Did I miss
anything?
Any suggestion or hints are welcome!
WY100

 // it tells Camel how to configure the REST service
restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.auto);

// Now define the REST API (POST, GET, etc.)
rest().path("/api") // This makes the API available at http://host:port
/$CONTEXT_ROOT/api
.consumes("application/json").produces("application/json")
// HTTP: POST /api
.post().type(Schema.class)
   .route()
   .process(exchange->{
    if(isforwardtosap) {
    exchange.getIn().setHeader("forward2sap", Boolean.TRUE);
    LOG.info("forward2sap -> {}",exchange.getIn().getHeader("forward2sap"));
    }
    if(isforwardtorest) {
    exchange.getIn().setHeader("forward2rest", Boolean.TRUE);
    LOG.info("forward2rest ->
{}",exchange.getIn().getHeader("forward2rest"));
    }
   })

RE: json to Pojo convertion problem for camel Rest DSL

Posted by Wilken Marci J <MA...@dhsoha.state.or.us.INVALID>.
Hi,
Based on the "<" you are seeing in the error I think you are receiving XML not JSON in the package.  I've seen a similar message in CXF


-----Original Message-----
From: Wang Yan <wy...@gmail.com> 
Sent: Friday, August 27, 2021 1:20 AM
To: users@camel.apache.org
Subject: json to Pojo convertion problem for camel Rest DSL

Think twice before clicking on links or opening attachments. This email came from outside our organization and might not be safe.  If you are not expecting an attachment, contact the sender before opening it.

Hello All,

I am using  camel RestDSL to get Json and conver it to pojo by
.post().type(Schema.class)
but i got below exception
org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value: < *srroy i need to hide package name
here* >Schema


below is the snippet of my code. i could not find any problem. Did I miss anything?
Any suggestion or hints are welcome!
WY100

 // it tells Camel how to configure the REST service
restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.auto);

// Now define the REST API (POST, GET, etc.)
rest().path("/api") // This makes the API available at https://urldefense.com/v3/__http://host:port__;!!OxGzbBZ6!KkxjugbqviBOiYGGMz5qvVKfEqyB4bBXKCcBUIob1b0h25VR8yKT7Y4QY1Y0hiFduktc1puCMh4g$
/$CONTEXT_ROOT/api
.consumes("application/json").produces("application/json")
// HTTP: POST /api
.post().type(Schema.class)
   .route()
   .process(exchange->{
    if(isforwardtosap) {
    exchange.getIn().setHeader("forward2sap", Boolean.TRUE);
    LOG.info("forward2sap -> {}",exchange.getIn().getHeader("forward2sap"));
    }
    if(isforwardtorest) {
    exchange.getIn().setHeader("forward2rest", Boolean.TRUE);
    LOG.info("forward2rest ->
{}",exchange.getIn().getHeader("forward2rest"));
    }
   })