camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Setting rest response json directly
Date Wed, 05 Nov 2014 06:22:54 GMT

And using

    .setBody(simple("{ \"error\": \"${exception.message}\" }"))

Does not work?

On Wed, Nov 5, 2014 at 7:02 AM, Gary Kennedy <> wrote:
> Greetings all,
> I'm using the camel rest dsl in a karaf osgi blueprint to define my route (and I love
it, so easy), and I've got an onException block properly handling my (known) exceptions for
an 'application/json' POST endpoint.
> I've set it to produce 'application/json' and when things go well it works fine.
> However, on the exception case I want to respond with a json body containing the exception
> e.g., { "error": "${exception.message}" }
> When I use setBody to do the above, the response is a json string of the above instead
of the above as json. (Does that make sense??)
> So how can I set a json response body from a simple (dsl) string?
> Cheers,
> Gary

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message