I working on an AWS Lambda function in python, sample below, and hooked up to an API Gateway via lambda_proxy integration. I have a post method in my api, which posts a json object in the request body as such:
{'request' : 'here are the details'}
In the lambda function I read the payload as such. This works but when there is a newline character in the request string, I get a json decode error
. How to fix this?
import json
def lambda_handler(event, context):
#read body
body = json.loads(event['body'])
#print body
...
i did the json.dumps(event) , output below
{
"resource": "/myresource",
"path": "/myresource",
"httpMethod": "POST",
"headers": {
...
},
...
"body": "{\"request\": \"here are the details \nhere some other details\"}",
"isBase64Encoded": false
}
....
}