350-201 exam dumps

350-201 practice question 243 of 289

Cybersecurity Professional - Performing Cybersecurity Using Cisco Security Technologies. Professional level, Cisco. Free question with the correct answer and a full explanation.

350-201 Question 243

Single answer

A network administrator is using a Python script to extract logs from a Cisco Secure Firewall via its REST API. Below is a snippet of the script:

import requests

url = "https://firewall/api/logs"
headers = {
    "Authorization": "Bearer <access_token>",
    "Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.status_code)

What is the purpose of the response.json() method in the script?

  1. A

    It sends a JSON-formatted request to the API endpoint.

  2. B

    It parses the JSON response from the API into a Python dictionary.

  3. C

    It verifies the status code of the API response.

  4. D

    It converts the Python dictionary into a JSON string.

Show answer and explanation

Correct answer: B

Explanation

The response.json() method is used in Python scripts that interact with APIs to convert a JSON response from the server into a Python dictionary. This allows the script to easily process the data returned by the API. Understanding the use of such methods is essential for leveraging automation in cybersecurity tasks, such as extracting logs or managing configurations via REST APIs.

  • A. Incorrect.

    Incorrect. The response.json() method does not send any request; it is used to handle the response data from the API.

  • B. Correct.

    Correct. The response.json() method parses the JSON response from the API and converts it into a Python dictionary for further use in the script.

  • C. Incorrect.

    Incorrect. Verifying the status code is done using the response.status_code property, not response.json().

  • D. Incorrect.

    Incorrect. The response.json() method works in the opposite direction; it converts JSON data into a Python dictionary, not the other way around.

Timed practice exam

Take a 350-201 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam