You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hairinwind <ro...@gmail.com> on 2012/06/20 02:43:31 UTC

How to post to restful service in camel routes?

I need get data from csv file and then post it to a external restful service. 

My route is like this 

from("file:data/inbox/?fileName=sample.csv&noop=true").
                unmarshal().csv()
                .split(body())
                .bean(new MyBean())
                .setHeader(Exchange.HTTP_METHOD, constant("POST"))
                .to("http://server/RestService/service/show/1");

I got the error 

org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value: my.exampl.MyBean@7df60a

What should I do ???

Thanks,

--
View this message in context: http://camel.465427.n5.nabble.com/How-to-post-to-restful-service-in-camel-routes-tp5714698.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to post to restful service in camel routes?

Posted by hairinwind <ro...@gmail.com>.
Thanks!
You are right :)  

--
View this message in context: http://camel.465427.n5.nabble.com/How-to-post-to-restful-service-in-camel-routes-tp5714698p5714789.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to post to restful service in camel routes?

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 20, 2012 at 2:43 AM, hairinwind <ro...@gmail.com> wrote:
> I need get data from csv file and then post it to a external restful service.
>
> My route is like this
>
> from("file:data/inbox/?fileName=sample.csv&noop=true").
>                unmarshal().csv()
>                .split(body())
>                .bean(new MyBean())
>                .setHeader(Exchange.HTTP_METHOD, constant("POST"))
>                .to("http://server/RestService/service/show/1");
>
> I got the error
>
> org.apache.camel.InvalidPayloadException: No body available of type:
> java.io.InputStream but has value: my.exampl.MyBean@7df60a
>
> What should I do ???
>

The message to be send to the reset service should be String based so
it can be posted over HTTP.
So check the return type of the bean call you do, eg MyBean. That
seems to return a MyBean instance.



> Thanks,
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-post-to-restful-service-in-camel-routes-tp5714698.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen