I am trying to send a API Gateway Response code of 401 if the user is missing required fields in header. The response from my lambda is as follows:
{
"status": "Unauthorized user",
"body": ["username"]
}
In the AWS API Gateway -> myAPI -> resource -> PUT operation -> Integration Response, I have 2 entries.
1. For all success with default RegEx Pattern (blank) --> Method response status of 201
2. For regex matching, if I use above JSON and below regex using regex or online regex101.com, there is a full match.
.*\"Unauthorized user\".*
However, the same fails during Test of API with below message
<date_time in UTC> : Endpoint response body before transformations: {"status": "Unauthorized user", "body": ["username"] }
<date_time in UTC> : Execution failed due to configuration error: No match for output mapping and no default output mapping configured. Endpoint Response Status Code: 200
<date_time in UTC> : Method completed with status: 500
Has anybody faced this? I end up getting a 201 if I have 201 with blank regex... irrespective of Unauthorized or internal error or bad requests.

