Last active
March 3, 2020 09:41
-
-
Save rpgreen/5cd3d5c872781335a5d3 to your computer and use it in GitHub Desktop.
An API Gateway mapping template to output all HTTP parameters in the JSON body
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set($allParams = $input.params()) | |
{ | |
"body-json" : "$input.json('$')", | |
"params" : { | |
#foreach($type in $allParams.keySet()) | |
#set($params = $allParams.get($type)) | |
"$type" : { | |
#foreach($paramName in $params.keySet()) | |
"$paramName" : "$util.escapeJavaScript($params.get($paramName))" | |
#if($foreach.hasNext),#end | |
#end | |
} | |
#if($foreach.hasNext),#end | |
#end | |
} | |
} |
This mapping template just results in errors for me, even when removing the quotes around $input.json('$'). :(
{"message": "Could not parse request body into json: Unrecognized token 'json': was expecting ('true', 'false' or 'null')\n at [Source: [B@41ebdee4; line: 1, column: 6]"}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@carlnordenfelt Thanks! That quotes cost me several hours.....