The documentation states that the json should return containing a body,headers,and a status code all of which I have. However for whatever reason when I test it in API gateway it returns a malformed response.
This is the output of the method below it.
"{\"body\": 200, \"headers\": {\"Content-type\": \"application/json\"}, \"statusCode\": 200}"
def addnumbers(message, context):
result = message['num1'] + 1
print(result)
resp = {
"statusCode": 200,
"body": result,
"headers": { "Content-type": "application/json"}
}
return (json.dumps(resp))
I am currently passing in num1=1 and it doesn't give any better error message. Any guidance would be appreciated.
json.dumps
? Simplyreturn resp
? – Mark BEndpoint response body before transformations: {"stackTrace": [["/var/task/lambda_function.py", 5, "addnumbers", "result = message['num1'] + 1"]], "errorType": "KeyError", "errorMessage": "'num1'"}
– Mark B