Issue at hand : Malformed Lambda exception only when accessing event data.
When I access the event, API Gateway returns an "Internal server error". A simplified use case of something I'd like to do would be to access the values of a key given to the Lambda from a POST request, proxy integration is used so there should be no need for template mapping.
import json
def lambda_handler(event, context):
items = {}
items["hello"] = "name"
itemsarray = []
for key, value in event.items() :
itemsarray.append(key + ":" + value)
return {
'statusCode': 200,
'isBase64Encoded': False,
'body' : json.dumps(items),
'headers': {
'content-type': 'application/json'
}
};
Error Message from API Gateway, Lambda itself returns no errors on the code.
Thu Feb 15 13:24:51 UTC 2018 : Received response. Integration latency: 742 ms
Thu Feb 15 13:24:51 UTC 2018 : Endpoint response body before transformations: {"errorMessage": "must be str, not NoneType", "errorType": "TypeError", "stackTrace": [["/var/task/lambda_function.py", 9, "lambda_handler", "itemsarray.append(key + \":\" + value)"]]}
Thu Feb 15 13:24:51 UTC 2018 : Execution failed due to configuration error: Malformed Lambda proxy response
Thu Feb 15 13:24:51 UTC 2018 : Method completed with status: 502
JSON Post Data
{ "dummy": "hello", "data": "world" }