1
votes

I want to set a 404 response code in API Gateway based on error message from Lambda function, here's integration response mapping:

enter image description here

And here's testing output:

enter image description here

The issue is that when making request in browser, I still don't get 404 status code, but rather the default one. What could the issue be here?

2

2 Answers

0
votes

On your method execution configuration, you need to set 404 as a status both on your Method Response and both at your Integration response. First you set it on your Method Response configuration and the you proceed in configuring the Integration response for 404.

0
votes

When invoking the deployed API's URL from the browser, the behavior should be the same as invoking from API Gateway console (as shown in above screenshot). Please make sure you have deployed to the stage that you are invoking, after you made all the configuration changes to the API.