Reputation: 301
I am trying to enter an invalid password, or even throw an exception in my AWS Lambda project (note that this is not an AWS Serverless project). No matter what I do, the status is always 200:
Here is code:
Here is API Gateway:
I have no other idea how to make this return bad request :(
Upvotes: 0
Views: 978
Reputation: 301
So I already made it work, what the code needs to look like is something like this:
public APIGatewayProxyResponse TestAbcAsync(APIGatewayProxyRequest request, ILambdaContext context)
{
var loginRequest = JsonConvert.DeserializeObject<LoginRequest>(request.Body);
return new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,
Body = loginRequest.Username,
};
}
Then the setup in API Gateway needs to have this checked:
The "Use Lambda Proxy Integration" should be checked
Upvotes: 1
Reputation: 11889
You ARE returning a 200. You need to return something like NotFound()
or BadRequest()
. You are just returning some (valid) json.
Upvotes: 0