Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I tried:


    "values": "$input.params()"


but did not work, I don't see the actual form data. BTW I am posting using:


I get my response from my lambda function, so I know it is invoking lambda fine, but my problem is that I don't see the POST params anywhere. I can't figure out how to map them. I dump all I get on Lambda side and here it is:

 {"values":"{path={}, querystring={}, header={Accept=*/*, Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.8, Cache-Control=no-cache, CloudFront-Forwarded-Proto=https, CloudFront-Is-Desktop-Viewer=true, CloudFront-Is-Mobile-Viewer=false, CloudFront-Is-SmartTV-Viewer=false, CloudFront-Is-Tablet-Viewer=false, CloudFront-Viewer-Country=US, Content-Type=application/x-www-form-urlencoded, Origin=chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop, Postman-Token=7ba28698-8753-fcb1-1f48-66750ce12ade, Via=1.1 (CloudFront), X-Amz-Cf-Id=sc8C7dLcW0BHYopztNYrnddC0hXyFdBzHv0O9aWU1gKhd1D_J2HF3w==, X-Forwarded-For=,, X-Forwarded-Port=443, X-Forwarded-Proto=https}}"}

1 Answer

0 votes
by (44.4k points)

This is an understandable and a robust mapping template which will work for almost all cases of POST and mainly for application/x-www-form-urlencoded


    "data": {

        #foreach( $token in $input.path('$').split('&') )

            #set( $keyVal = $token.split('=') )

            #set( $keyValSize = $keyVal.size() )

            #if( $keyValSize >= 1 )

                #set( $key = $util.urlDecode($keyVal[0]) )

                #if( $keyValSize >= 2 )

                    #set( $val = $util.urlDecode($keyVal[1]) )


                    #set( $val = '' )


                "$key": "$val"#if($foreach.hasNext),#end





It would transform an input of




    "data": {

                "name": "kodee",

                "email": "[email protected]",

                "message": ""



To return all the input data, this Lambda function can be used:

module.exports.handler = function(event, context, cb) {

  return cb(null, {




Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories