0
votes

I have a lambda which returns statusCode, body and isBase64Encoded as defined in https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html .

But after the api gateway integration (as lambda integration not lambda proxy), it returns exactly that in response.

{
  "statusCode": 200,
  "body": "{\"key1\":\"value 1\",\"foo\":\"bar\"}",
  "isBase64Encoded": false
}

Do I need something in response mapping template to convert this lambda response to proper http response?

1
if you are not using Lambda Proxy, whatever json you send back from Lambda will be returned to client. so, i would recommend just passing {"key1":"value 1","foo":"bar"}Balu Vyamajala

1 Answers

0
votes

LAMBDA_PROXY : Request body is surrounded with details related to request which includes headers, keys, context, query parms, etc. similarly the response json should be converted to string and be wrapped within json along with statusCode. Exactly how it is in question.

where as LAMBDA non Proxy integration request from client is passed as is to lambda and response from Lambda is also passed back to client as is.

Since you are using non proxy integration, response from lambda should simply be a json {"key1":"value 1","foo":"bar"}

Status Code for Non-Proxy Integration is always 200 OK, irrespective of Lambda execution is success or failure.