0

So I have followed this gudie from another stack question:

The steps to get this working are:

  1. go to Resources -> Integration Request
  2. click on the plus or edit icon next to templates dropdown (odd I know since the template field is already open and the button here looks greyed out)
  3. Explicitly type application/json in the content-type field even though it shows a default (if you don't do this it will not save and will not give you an error message)
  4. Put this in the input mapping { "name": "$input.params('name')" }
  5. click on the check box next to the templates dropdown (I'm assuming this is what finally saves it)

I understand this however I don't understand how I can then use this parameter within my lambda function (Python)

I have tried input.name with no success.

abhi
  • 1,760
  • 1
  • 24
  • 40
user3024827
  • 1,228
  • 4
  • 18
  • 36
  • i get this error when I run in in the API "errorMessage": "'builtin_function_or_method' object has no attribute name – user3024827 Feb 19 '16 at 15:16
  • 1
    Could you please refer the question you are talking about? Also if you can show us your code, we can help you out as best we can. – abhi Feb 19 '16 at 15:31
  • http://stackoverflow.com/questions/31329958/how-to-pass-a-querystring-or-route-parameter-to-aws-lambda-from-amazon-api-gatew – user3024827 Feb 19 '16 at 15:35

1 Answers1

0

You can use query strings like this:

UserName = event["UserName"] 

Here is an example with Python:

def lambda_handler(event, context):
import boto3
import json
import decimal

# Helper class to convert a DynamoDB item to JSON.
class DecimalEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, decimal.Decimal):
            if o % 1 > 0:
                return float(o)
            else:
                return int(o)
        return super(DecimalEncoder, self).default(o)

dynamodb = boto3.resource('dynamodb', region_name='ap-southeast-1', endpoint_url="http://dynamodb.ap-southeast-1.amazonaws.com")
table = dynamodb.Table('TableUsers')

UserName =event["UserName"]
UserId = event["UserId"]
UserPassword=event["UserPassword"]

response = table.put_item(
   Item={
        'UserName': UserName,
        'UserId': UserId,
        'UserPassword':UserPassword
    }
)
return "Register Successfully"
illright
  • 3,991
  • 2
  • 29
  • 54
Rahul Gaikwad
  • 563
  • 4
  • 9
  • 26