API Gateway - Body Mapping Template - optional body parameters

I have a POST API Gateway method, which I am sending the following application/json body in order to pass it to a Lambda that the method is connected to:

{      "otherClientId": "12345",     "message": "Text",     "seconds": 0,     "hours": 0 } 

I am using the following mapping template:

#set($inputRoot = $input.path('$')) {   "authorizedUser": "$context.authorizer.principalId",   "otherClientId": "$inputRoot.otherClientId",   "message": "$inputRoot.message",   "amount": $inputRoot.amount,   "duration": $inputRoot.duration } 

The problem I am experiencing is that I receive a "Bad String" error when attempting to send the request without amount or duration. For some reason these parameters do not seem to be optional (but I need them to be!). I am able to miss out other parameters, like message for instance, but not the two number parameters.

Has anybody else experienced this or can somebody point out the obvious that I am probably missing? The AWS documentation is a little sparse on the subject.


Category: amazon web services Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.221 (s). 12 q(s)