The body of my post request to rest camel component is not in the form of a json. Hence I am not able to extract the key-value pairs. How do I convert body into json? I sent a json object of this type
{
"filename": "hello.txt",
"bucketName": "cameltry",
"accessKey": "key",
"secretKey": "key",
"region" : "us-east-1"
}
I have to use this json data to download a file from AWS S3. The corresponding route in camel is:
public static class HelloRoute extends RouteBuilder {
@Override
public void configure() {
rest("/")
.post("file-from-s3")
.route()
.setHeader(AWS2S3Constants.KEY, constant($body[filename]))
.toD("aws2-s3://${body[bucketName]}?accessKey=${body[accessKey]}&secretKey=${body[secretKey]}®ion=${body[region]}&operation=getObject")
.to("file:/tmp/")
.endRest();
}
Here $body[filename]
turns out to be null as $body
is not a json object. How do I convert it into a json object?