1

i hope this isn't a duplicate. I searched through other entries and none seemed to address the problem i'm seeing.

We have an AWS Lambda function written in Python 3.6. The Lambda function is executed through API Gateway using the Lambda proxy integration. The function is initiated without problem and the processing executes without a problem. However, no matter what we seem to do in trying to send a response, the client receives "{"message": "Internal server error"}" I don't know that it's important, but the client for our test is Postman.

We've stripped out all of our business logic and isolated the code that does the return and we still get have the same problem.

the code is:

    import json
    def lambdaTest(event, context)
        response = {}
        dummybody = {'body':'something'}
        response['statusCode'] = 200
        response['body'] = dummybody
        response["headers"] = {"Content-Type": "application/json"},
        return json.dumps(response)

i'm sure I'm doing something wrong that's simple as I don't seem many posts about this problem. I would very much appreciate any help. Thanks.

2
  • Have you tried to return just return response without json.dumps()? Commented Aug 23, 2018 at 9:41
  • Thank for the thought. I did. Same thing Commented Aug 23, 2018 at 12:17

1 Answer 1

3

Folks, I figured it out... one silly problem and one thing I didn't realize about the format of the response. The silly problem was that I turned the header element into an array because I had a trailing comma (I looked at the 100 times and didn't see it). But even when I commented out setting up the header, it still had the same problem. The aspect of the response that i didn't realize is that the body is expected to be a string. So, I had to encapsulate the JSON document I wanted to return in a string. That fixed the problem.

i hope this can help someone else

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.