I am getting a 500 Internal Server Error
with the following code in an AWS Lambda function and I cannot figure out why. The python code runs fine locally without any exceptions.
def lambda_handler (event, context):
return {
"statusCode": 200,
'headers': {
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
},
"body": [],
}
CodePudding user response:
The problem is that body
MUST BE A STRING. Objects will not work.
The (very simple) solution that took me an hour or so to figure out:
def lambda_handler (event, context):
return {
"statusCode": 200,
'headers': {
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
},
"body": "[]",
}