Ankur
Ankur

Reputation: 127

AWS lambda returning Internal server error for simple return json code based on python for no reason

In Lambda function, I am returning output as below

output = {
            "statusCode": 200,
            "headers": {'Content-Type': 'application/json'},
            "body": json.dumps({'success': true})
        }
        #json.dumps('Email sent! Message ID:' + response['MessageId'])
        return output

and it returns following error message:

{
    "message": "Internal server error"
}

However if I change following line

json.dumps({'success': true})

to

json.dumps('Email sent! Message ID:' + response['MessageId'])

It works fine. I want to return a json back, what needs to be done?

Upvotes: 0

Views: 418

Answers (1)

Manohar Kotapati
Manohar Kotapati

Reputation: 111

I think python's Json Boolean value has to be either True or False (First letter capital).
Try json.dumps({'success': True})

Upvotes: 1

Related Questions