AWS API Gateway: Regex for error is not picked up

Viewed 2692

I have a Lambda function tied to the AWS API gateway. When I call it with something like /foo/bar and bar does not exist, my function returns (correctly) something like:

{
  "code": 404,
  "message": "bar not found"
}

I now want the status code of this to be 404, too, but following the tutorials I could find on the net, I had no success so far. What I did:

I created a method response for 404 that looks like this: 404 response

And in the integration response, I set the following: 404 integration response

To my understanding, this should set the code to 404 when 404 appears in the response document, but I still get 200.

What am I missing?

1 Answers
Related