I have a lambda function, which is returning me a value from dynamdb table. The value is in nested jason format.
When I test the lambda in it's own console it is working fine. BUT When I integrate it with API gateway it is giving me an internal server error with this message.
Execution failed due to configuration error: Malformed Lambda proxy response
here is my response body
return {
"isBase64Encoded": "true",
"statusCode": 200,
"headers": { "Access-Control-Allow-Methods": "*", "Access-Control-Allow-Headers": "*", "Access-Control-Allow-Origin": "*" },
"body": response
}
Does anyone know this issue.
I tried with
return {
"isBase64Encoded": "true",
"statusCode": 200,
"headers": { "Access-Control-Allow-Methods": "*", "Access-Control-Allow-Headers": "*", "Access-Control-Allow-Origin": "*" },
"body": json.dumps(response['Items'])
}
it seems to be working.
What is the issue causing this? because if I have a normal JSON.
"body": response
works properly. The issue only comes when there is nested JSON
Here is the JSON object:
[
{
"time_stamp":"2021-01-13 06:02:42",
"broker_id":"broker1",
"load_id":"ab6fd05f-3f54-44dc-ae6d-28e924fe1ae2",
"messages":[
{
"date":"22:32",
"messanger_id":"[email protected]",
"message":"Hello",
"user":"carrier"
},
{
"date":"22:35",
"messanger_id":"[email protected]",
"message":"Hi",
"user":"broker"
}
],
"carrier_id":"carrier1"
},
{
"time_stamp":"2021-01-13 06:03:32",
"broker_id":"broker1",
"load_id":"ab6fd05f-3f54-44dc-ae6d-28e924fe1ae2",
"messages":[
{
"date":"22:32",
"messanger_id":"[email protected]",
"message":"Hello",
"user":"carrier"
},
{
"date":"22:35",
"messanger_id":"[email protected]",
"message":"Hi",
"user":"broker"
}
],
"carrier_id":"carrier2"
}
]
responseobject?Items, but you are usingresponse['Items']?"body": responsedoes not work, not"body": response["Items"]? Can you clarify please what works, what does not, and what is the example you provided.