camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Lichtin <lich...@yahoo.com.INVALID>
Subject Re: Rest DSL - how to pass PUT body as method argument
Date Mon, 18 Sep 2017 19:37:07 GMT
To answer my question, yes this works.
The JSON body is deserialized and passed on as a MyOrder object to the update() method.

One issue with Rest PUT/POST is that Camel will use the request body also for the HTTP response.
Usually this is not wanted, so best to empty the out body, e.g. with <setBody><simple>null</simple></setBody>

On 16.09.2017 18:34, Martin Lichtin wrote:
> Camel Rest DSL
>
> Want to ask how can one pass the body of a PUT request to a method positional argument.
> Eg, with bindingMode=json will the magic ${body} work?
>
>     <rest path="/order">
>       <put uri="/{id}" type="MyOrder">
>         <to uri="bean:orders?method=update(${header.id},${body})" />
>       </put>
>     </rest>
>
> with the method in Java as
>
>     update(String id, MyOrder myOrder)
>
> Searched the docs (including Camel in Action, 2nd ed), but can't find an example anywhere.

Mime
View raw message