0

This article describes how to create an HTTP API that calls a Lambda under a node runtime.

I just tried doing the same with a Python lambda with the following handler:

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': "\"Hello from Lambda!\""
    };

When tested within the Lambda editor, this Lambda returns the exact same as the node Lambda from the article, namely

{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

However, the node function works when attached to an HTTP API and navigated to in the browser, while the Python one gives a

{"message":"Internal Server Error"}

What can I do to make it work?

1 Answer 1

2

I suggest checking out Cloudwatch logs for details.

It may from your return string. Let's give it a try.

import json
def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": json.dumps('Cheers from AWS Lambda!!')
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Haha I can't believe I should have just tried the default template. Well thanks very much and I'll look at the logs if I have more problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.