The default API Gateway setup don't include the raw body of a POST
See original GitHub issue- Expected behaviour:
It should be possible to use claudiajs (and caudia-api-builder) to deploy lambdas that expects the raw body of a POST request in a parameter.
- Use case:
An use case for this is the signature verification on a Facebook Messenger Bot for example, that sends a signature for the raw body + a secret in the header (see https://developers.facebook.com/docs/messenger-platform/webhook-reference#security )
- What actually happens:
The Body Mapping Template used by claudia is the one at https://github.com/claudiajs/claudia/blob/master/json-templates/apigw-params.txt that does not include the raw body, and the CLI don’t have an option to override that template with a different one.
- Workaround
Either manually add the patch on the body mapping template at AWS website:
...
"rawBody": "$util.escapeJavaScript($input.body).replace("\'", "'")",
...
Or patch the apigw-params.txt manually.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top GitHub Comments
I wouldn’t count on just facebook needing this, so adding rawBody for application/json in general would be my preferred option.
I’ve copy/pasted the previous test, hope it’s ok 😛