nerdexam
Cisco

350-401 · Question #616

Which Python code snippet must be added to the script to save the returned configuration as a JSON-formatted file? A. B. C. D.

The correct answer is B. with open("ifaces.json", "w") as OutFile: OutFile.write(Response.text). Option B is correct because Response.text returns the raw string content of the HTTP response, which is already in JSON format (as text), and writing it directly to a file with 'w' mode saves it as a valid JSON-formatted file. The file is opened in write mode ('w') which is appro

Submitted by eva_at· Mar 6, 2026Network Programmability and Automation - Working with REST APIs and saving API responses using Python, typically aligned with Cisco DevNet or CCNP/CCIE Enterprise certification objectives.

Question

Which Python code snippet must be added to the script to save the returned configuration as a JSON-formatted file? A. B. C. D.

Exhibits

350-401 question #616 exhibit 1
350-401 question #616 exhibit 2

Options

  • Awith open("ifaces.json", "w") as OutFile: OutFile.write(Response)
  • Bwith open("ifaces.json", "w") as OutFile: OutFile.write(Response.text)
  • Cwith open("ifaces.json", "w") as OutFile: JSONResponse = json.loads(Response.text) OutFile.write(JSONResponse)
  • Dwith open("ifaces.json", "w") as OutFile: OutFile.write(Response.json())

How the community answered

(65 responses)
  • A
    3% (2)
  • B
    75% (49)
  • C
    8% (5)
  • D
    14% (9)

Explanation

Option B is correct because Response.text returns the raw string content of the HTTP response, which is already in JSON format (as text), and writing it directly to a file with 'w' mode saves it as a valid JSON-formatted file. The file is opened in write mode ('w') which is appropriate, and Response.text preserves the JSON string exactly as received from the API.

Topics

#Python Requests Library#REST API#JSON File Handling#Network Automation

Community Discussion

No community discussion yet for this question.

Full 350-401 Practice