mediumMultiple ChoiceObjective-mapped
350-401 Practice Question: Writes the following Python script to collect…
A network engineer writes the following Python script to collect telemetry data from a Cisco IOS-XE device using NETCONF:
```python
from ncclient import manager
m = manager.connect( host='192.168.1.1', port=830,
username='admin',
password='cisco', hostkey_verify=False )
filter = ''' <filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="http://openconfig.net/yang/interfaces"> <interface> <name>GigabitEthernet1</name> </interface> </interfaces> </filter> '''
reply = m.get(filter=('subtree', filter))
print(reply.xml)
m.close_session() ```
What is the issue with this code?
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
✓
The filter is passed as a string instead of a tuple with filter type.
The filter is passed as a string but the ncclient library expects a tuple with the filter type and the filter content. The correct syntax is filter=('subtree', filter_string). The code passes a single string, which will cause a TypeError.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The filter is passed as a string instead of a tuple with filter type.
Why this is correct
ncclient requires filter=('subtree', filter_xml) to specify the filter type.
- ✗
The hostkey_verify=False is insecure and should be set to True.
Why it's wrong here
While insecure, this is common in lab environments and not the primary issue.
- ✗
The interface name should be 'GigabitEthernet0/0' to match Cisco naming.
Why it's wrong here
The interface name in OpenConfig is typically 'GigabitEthernet1' and is not the cause of the error.
- ✗
The filter XML uses the wrong namespace for interfaces.
Why it's wrong here
The namespace http://openconfig.net/yang/interfaces is correct for OpenConfig.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 350-401 question from scratch — 1,175 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 by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 350-401 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 350-401 exam.