I understand that API Gateway (AG) passes params into Lambda as JSON payload.
I have setup a POST API with Lambda Proxy in AG. My lambda function takes the following param list :
{
"fullname": "Mr xxxxx",
"clientemail": "[email protected]",
"clientphone": "0800 088 8888",
"locationtext": "Laxxxxxx Hotel , CA, USA",
"subject": "Gxxxxxrth",
"appointmentblock_min": "60",
"buffer": "120",
"calendar_id": "xxxxx",
"thedate": "2021-03-2xxxxxx",
"thetime": "xxxxx"
}
Testing directly within the Lambda console. Everything works fine. I map all parameters in the code using the lambda EVENT object as follows :
fullname = event['fullname']
clientemail = event['clientemail']
appointmentblock_min = int(event['appointmentblock_min'])
... and so on.
All code works fine.
Adding the API Gateway component on top ... and things don't work.
The specific problem : how can I map the lambda input parameters coming from API Gateway (AG) to lambda ? I realise that AG is sending JSON into Lambda. How to parse this payload to extract and use the parameters that I need.
I have tried to create a dict containing all the parameters :
Event = {}
Event = json.loads(body)
Event = json.loads(event.body)
No docs explicitly explain how to grab the event object params via AG.
Any help would be appreciated.
PS I am expecting to return data back to AG as follows :
return {
'statusCode': 200,
'headers': {'Content-Type': 'application/json'},
'body': json.dumps(out_message),
'isBase64Encoded': 'false'
}
Thank you for your consideration.