200-901 Network Fundamentals Practice Question
A developer is writing a Python script that uses the requests library to interact with a REST API. The script must handle common HTTP status codes appropriately. Which two actions should the developer take to ensure robust error handling? (Choose two.)
⚠ Common exam trap
The trap here is thinking that increasing timeout or disabling SSL verification makes the script more robust, when they actually introduce fragility or security risks.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Check the response.status_code attribute and branch logic based on the code.
To robustly handle HTTP errors, the developer should check the status code and branch logic accordingly, and use raise_for_status() to raise exceptions for 4xx and 5xx responses. These practices allow the script to respond appropriately to different error conditions, such as retrying or logging. Other options either introduce risks or do not address error handling effectively.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Always assume the response is JSON and parse it without checking the Content-Type header.
Why it's wrong here
Assuming the response is JSON can lead to parsing errors if the server returns HTML or plain text, especially for error responses. Robust scripts should check the Content-Type header or use try-except around JSON parsing. Ignoring the content type can cause the script to crash or behave unexpectedly. Thus, this is not a recommended practice.
- ✗
Disable SSL verification to avoid certificate errors.
Why it's wrong here
Disabling SSL verification (verify=False) introduces security risks, such as man-in-the-middle attacks. It does not contribute to robust error handling; instead, it hides potential security issues. Proper handling involves ensuring valid certificates or configuring trusted CAs. Therefore, this is not a recommended action for a production script.
- ✓
Check the response.status_code attribute and branch logic based on the code.
Why this is correct
Checking the status_code allows the script to handle different HTTP responses explicitly. For example, a 200 indicates success, while 404 means the resource was not found, and 500 indicates a server error. By branching logic, the developer can implement retries for 5xx errors or display user-friendly messages for 4xx errors. This is a fundamental practice for robust API interaction.
- ✗
Set the timeout parameter to a very high value to avoid connection errors.
Why it's wrong here
Setting a high timeout does not improve error handling; it can cause the script to hang for a long time if the server is unresponsive. A better practice is to set a reasonable timeout and handle the Timeout exception. A high timeout may mask network issues and degrade user experience. Therefore, this is not a recommended action for robust error handling.
- ✓
Use response.raise_for_status() to automatically raise an exception for 4xx and 5xx responses.
Why this is correct
The raise_for_status() method raises an HTTPError exception if the response contains an unsuccessful status code (4xx or 5xx). This simplifies error handling because the developer can wrap the request in a try-except block. It ensures that errors are not silently ignored and allows centralized handling of HTTP errors, making the script more robust.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 200-901 question from scratch — 975 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.