Zet - How do I get the body from an apigateway call using the $input template vtl syntax?

How do I get the body from an apigateway call using the $input template vtl syntax?

You can use $input.json('$') just remember to wrap it in $util.escapeJavaScript to catch any bad escapes.

{
    "name" : "$input.params('name')",
    "body" : $util.escapeJavaScript($input.json('$'))
}

see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#input-examples-mapping-templates

#aws #aws-gateway