Rest API - HTTP Status CodesWhen should a REST API return a 422 Unprocessable Entity status code?AWhen the user is not authenticatedBWhen the requested URL does not existCWhen the request body is syntactically correct but contains invalid dataDWhen the server is down for maintenanceCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify the condition for 422422 is used when the request syntax is correct but the data is invalid or semantically wrong, like missing required fields or invalid formats.Step 2: Eliminate other options404 is for missing URLs, 401 for authentication, and 503 for server maintenance, so they don't fit 422.Final Answer:When the request body is syntactically correct but contains invalid data -> Option CQuick Check:422 triggers on invalid data, not missing URL or auth [OK]Quick Trick: Use 422 for valid syntax but invalid data [OK]Common Mistakes:Returning 404 instead of 422 for bad dataUsing 401 for data validation errorsConfusing 422 with server errors
Master "HTTP Status Codes" in Rest API9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Rest API Quizzes HTTP Methods - PATCH for partial updates - Quiz 5medium HTTP Methods - POST for creating resources - Quiz 2easy REST API Fundamentals - REST vs SOAP vs GraphQL comparison - Quiz 3easy REST API Fundamentals - REST constraints and principles - Quiz 9hard REST API Fundamentals - REST vs SOAP vs GraphQL comparison - Quiz 4medium Request and Response Format - JSON as standard format - Quiz 6medium Request and Response Format - Response envelope patterns - Quiz 9hard URL and Resource Design - Nested resources - Quiz 2easy URL and Resource Design - Plural vs singular resource names - Quiz 8hard URL and Resource Design - Nested resources - Quiz 3easy