Courseiva

200-901 Infrastructure and Automation Practice Question

A developer is writing a Python script that calls the Cisco DNA Center Intent API to retrieve a list of network devices. The script must handle the case where the API returns a 401 Unauthorized response by obtaining a new authentication token and retrying the request. Which Python construct should be used to implement this retry with token refresh?

⚠ Common exam trap

The trap here is assuming that simply retrying the same request will eventually succeed, when in fact the token must be refreshed first.

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

✓

A try/except block that catches requests.exceptions.HTTPError, checks the response status code, and if it is 401, obtains a new token using the DNA Center authentication endpoint and retries the original request.

The correct approach uses exception handling to catch the HTTP error from the failed request, then performs a token refresh via the DNA Center authentication API and retries the original request. This pattern is essential for robust API clients that must handle token expiration. The other options either loop without refreshing credentials, use static tokens, or abort without recovery, none of which solve the authentication failure scenario.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A while loop that continuously sends the same request with the same token until a 200 OK response is received.

    Why it's wrong here

    A while loop that resends the same request with an unchanged token will never succeed if the token is invalid; it will keep receiving 401 responses indefinitely. This does not refresh the token and could cause an infinite loop, so it fails to meet the requirement of handling authentication failure gracefully.

  • ✗

    A conditional statement that checks the response status code before sending the request and, if it is not 200, aborts the script.

    Why it's wrong here

    Checking the response before sending the request is impossible because the response does not exist yet. Aborting on a non-200 status also does not retry or refresh the token, so it does not satisfy the requirement to recover from a 401 by re-authenticating and retrying the API call.

  • ✓

    A try/except block that catches requests.exceptions.HTTPError, checks the response status code, and if it is 401, obtains a new token using the DNA Center authentication endpoint and retries the original request.

    Why this is correct

    This approach correctly handles the 401 by catching the HTTPError raised by raise_for_status(), then re-authenticating via the DNA Center token endpoint and retrying. It directly addresses the scenario's requirement to refresh the token and retry on unauthorized responses, making it the appropriate Python construct for this error-handling flow.

  • ✗

    A for loop that iterates over a list of predefined tokens, sending the request with each token until one succeeds.

    Why it's wrong here

    Using a static list of tokens is impractical and insecure; tokens expire and must be obtained dynamically. This approach does not refresh the token from the authentication endpoint and assumes multiple valid tokens exist, which is not how Cisco DNA Center authentication works, so it is not a viable solution.

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 →

How Courseiva writes practice questions · Editorial policy

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.