Search code examples
amazon-web-servicesaws-lambdaaws-api-gatewayamazon-cloudwatchamazon-cloudwatchlogs

Why i am getting this {"message": "Internal server error" } from Postman


I am new to AWS, I am getting {"message": "Internal server error"} while running the Lambda function with API Gateway in Postman.

I have checked the CloudWatchLogs, there is no error showing in the logs. But Postman returning {"message": "Internal server error"} this error.


Solution

  • It happens when you don't return the correct API Gateway format.

    Try to return this in your Lambda:

    def lambda_handler(event, context):
        return {
            "statusCode": 200,
            "body": "{'Test': 'Test'}",
            "headers": {
                'Content-Type': 'text/html',
            }
        }