Developing Applications Using Cisco Core Platforms and APIs (DEVCOR) — Question 418
A developer is building an application to access a website. When running the application, an HTTP 403 error code has been received.
How should the application be modified to handle this code?
Answer options
- A. Create a loop on cancel the operation and run a new one after the code is received.
- B. Use exponential backoff when retrying distributed services and other remote endpoints.
- C. Build a try/except around the urlopen to find errors occurring in the request.
- D. Redirect the request to an internal web server and make a new request from the internal resource.
Correct answer: C
Explanation
The correct answer is C because wrapping the urlopen call in a try/except block allows the application to catch and handle the HTTP 403 error specifically. Options A and D do not address the error directly and may lead to further issues, while option B is more suited for handling transient errors rather than a specific HTTP error like 403.