0

I am using Lambda function to return custom responses for my api endpoint.

i am returning the responses like this -

response404 = {
        "statusCode": 404,
        "body": json.dumps({"message": "Not Found"})
        }
        
        if httpStatusCode == "200":
            return output_response
        else:
            return response404

It's returning the response but not setting the status code in Postman.

404

What do i need to do to set the status to 404 in postman as well.

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
Irfan
  • 37
  • 6

1 Answers1

0

This can be done by setting up a Lambda Proxy Integration.

enter image description here

The response of the lambda function needs to be in this format ->

response = {
        "statusCode": 404,
        "headers": {
            "Content-Type" : "application/json"
        },
        "body": json.dumps(error_handler)
    }

return response
Irfan
  • 37
  • 6