error_codes with exact error code keys and message valuesrequested_code with a specific error code stringrequested_codeJump into concepts and practice - no test required
error_codes with exact error code keys and message valuesrequested_code with a specific error code stringrequested_codeerror_codes with these exact entries: '404': 'Not Found', '500': 'Internal Server Error', '403': 'Forbidden'Use curly braces {} to create a dictionary with string keys and string values.
requested_code and set it to the string '404'Assign the string '404' to the variable requested_code.
error_message and set it to the value from error_codes using the key requested_codeUse square brackets [] to get the value from the dictionary using the key.
print statement to display the value of error_messageUse print(error_message) to show the message on the screen.
What is the main purpose of using error codes in a REST API?
Which HTTP status code correctly indicates a successful request in a REST API?
Choose the correct code:
Given this JSON error response from a REST API:
{
"status": 404,
"error": "Resource not found"
}What does the 404 status code mean?
Look at this REST API error response snippet:
{
"status": 200,
"error": "Invalid input data"
}What is wrong with this error code usage?
You want to design a REST API that returns error codes machines can easily understand and act on. Which approach is best?
Choose the best practice: