AWS Certified Developer – Associate (DVA-C02) — Question 299
A developer is testing a RESTful application that is deployed by using Amazon API Gateway and AWS Lambda. When the developer tests the user login by using credentials that are not valid, the developer receives an HTTP 405: METHOD_NOT_ALLOWED error. The developer has verified that the test is sending the correct request for the resource.
Which HTTP error should the application return in response to the request?
Answer options
- A. HTTP 401
- B. HTTP 404
- C. HTTP 503
- D. HTTP 505
Correct answer: A
Explanation
An HTTP 401 Unauthorized status code is the correct response when a request fails authentication due to invalid credentials. HTTP 404 indicates a resource was not found, while HTTP 503 and HTTP 505 represent server-side service unavailability and unsupported HTTP protocol versions respectively, making them incorrect for authentication issues.