<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ncclient get_cofig filter error in DevNet Sandbox</title>
    <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529514#M7178</link>
    <description>&lt;P&gt;Howdy! Using:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;sandbox-iosxe-latest-1.cisco.com&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;And the error I'm getting is the same as OP:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;&amp;lt;bad-element&amp;gt;filter&amp;lt;/bad-element&amp;gt;\n&amp;lt;/error-info&amp;gt;&lt;BR /&gt;&lt;BR /&gt;"Bad element". I can get_config with no filters just fine, but when I add an XML filter, I get the above error. Relatively new to doing this, so error could be on my end. Thanks for the help!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jan 2022 14:32:29 GMT</pubDate>
    <dc:creator>kenmartinmiller</dc:creator>
    <dc:date>2022-01-11T14:32:29Z</dc:date>
    <item>
      <title>ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4460784#M6569</link>
      <description>&lt;P&gt;Does anyone know why i am getting an error on get_config with ncclient?&amp;nbsp; may be the filter i am using is not right but the filter is from the iosxe lab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;netconf_filter = """&lt;BR /&gt;&amp;lt;filter&amp;gt;&lt;BR /&gt;&amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;&lt;BR /&gt;&amp;lt;/interfaces&amp;gt;&lt;BR /&gt;&amp;lt;/filter&amp;gt;"""&lt;/P&gt;&lt;P&gt;m = manager.connect(&lt;BR /&gt;host="10.10.20.100",&lt;BR /&gt;port="830",&lt;BR /&gt;username="developer",&lt;BR /&gt;password="C1sco12345",&lt;BR /&gt;hostkey_verify=False&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;netconf_reply = m.get_config(source = 'running', filter = netconf_filter)&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "/home/lam/DEVNET-Lab/netconf/lib/python3.8/site-packages/ncclient/manager.py", line 246, in execute&lt;BR /&gt;return cls(self._session,&lt;BR /&gt;File "/home/lam/DEVNET-Lab/netconf/lib/python3.8/site-packages/ncclient/operations/retrieve.py", line 166, in request&lt;BR /&gt;return self._request(node)&lt;BR /&gt;File "/home/lam/DEVNET-Lab/netconf/lib/python3.8/site-packages/ncclient/operations/rpc.py", line 375, in _request&lt;BR /&gt;raise self._reply.error&lt;BR /&gt;ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-element', 'app_tag': None, 'severity': 'error', 'info': '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;&amp;lt;bad-element&amp;gt;filter&amp;lt;/bad-element&amp;gt;\n&amp;lt;/error-info&amp;gt;\n', 'path': '\n /rpc/get-config\n ', 'message': None}&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 06:24:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4460784#M6569</guid>
      <dc:creator>pmlam3274</dc:creator>
      <dc:date>2021-09-07T06:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4460789#M6570</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/288213"&gt;@pmlam3274&lt;/a&gt;&amp;nbsp;which learning lab are you following? There was an issue with one of the always-on XE sandbox rejecting RESTCONF/NetConf at one stage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 06:31:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4460789#M6570</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2021-09-07T06:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529428#M7176</link>
      <description>&lt;P&gt;Howdy - were you able to get this resolved? I'm running into the same issue when attempting to pull data using an XML filter from the DevNet always on XE sandbox. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 11:49:55 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529428#M7176</guid>
      <dc:creator>kenmartinmiller</dc:creator>
      <dc:date>2022-01-11T11:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529507#M7177</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1257562"&gt;@kenmartinmiller&lt;/a&gt;&amp;nbsp;what is the sandbox you are using (there is two always on xe) and code/error you get?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 14:17:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529507#M7177</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2022-01-11T14:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529514#M7178</link>
      <description>&lt;P&gt;Howdy! Using:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;sandbox-iosxe-latest-1.cisco.com&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;And the error I'm getting is the same as OP:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;&amp;lt;bad-element&amp;gt;filter&amp;lt;/bad-element&amp;gt;\n&amp;lt;/error-info&amp;gt;&lt;BR /&gt;&lt;BR /&gt;"Bad element". I can get_config with no filters just fine, but when I add an XML filter, I get the above error. Relatively new to doing this, so error could be on my end. Thanks for the help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 14:32:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529514#M7178</guid>
      <dc:creator>kenmartinmiller</dc:creator>
      <dc:date>2022-01-11T14:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529539#M7179</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1257562"&gt;@kenmartinmiller&lt;/a&gt;&amp;nbsp;it depends on what data you are wanting, typically i use the native&amp;nbsp; model&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                 &amp;lt;config&amp;gt;
                    &amp;lt;native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"&amp;gt;
                        &amp;lt;router&amp;gt;
                            &amp;lt;ospf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-ospf"&amp;gt;
                            &amp;lt;/ospf&amp;gt;
                        &amp;lt;/router&amp;gt;
                    &amp;lt;/native&amp;gt;
                &amp;lt;/config&amp;gt;&lt;/PRE&gt;
&lt;P&gt;And then print the output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;reply = m.get_config(rpc, target='running')
        print(reply) &lt;/PRE&gt;
&lt;P&gt;Take a look at YANG suite,&amp;nbsp;&lt;A href="https://developer.cisco.com/yangsuite/" target="_blank"&gt;https://developer.cisco.com/yangsuite/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 15:09:01 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4529539#M7179</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2022-01-11T15:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: ncclient get_cofig filter error</title>
      <link>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4530724#M7190</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/352839"&gt;@bigevilbeard&lt;/a&gt;&amp;nbsp;thanks again for the help! Figured this out. 2 problems:&lt;BR /&gt;&lt;BR /&gt;1. I was targeting&amp;nbsp;&lt;STRONG&gt;sandbox-iosxe-latest-1.cisco.com&lt;/STRONG&gt;, which is currently running&amp;nbsp;&lt;SPAN&gt;17.3.1, which has a known issue with this exact scenario, documented here:&amp;nbsp;&lt;A href="https://community.cisco.com/t5/yang-tools/netconf-error-on-csr-1000v/td-p/4264458" target="_blank"&gt;https://community.cisco.com/t5/yang-tools/netconf-error-on-csr-1000v/td-p/4264458&lt;/A&gt;. Once I targeted&amp;nbsp;&lt;STRONG&gt;sandbox-iosxe-recomm-1.cisco.com&lt;/STRONG&gt; instead, which is running&amp;nbsp;16.9.3, the query started working.&lt;BR /&gt;&lt;BR /&gt;2. Instead of writing out the full XML filter, I started using&amp;nbsp;&lt;STRONG&gt;xpath&lt;/STRONG&gt; filtering. For example:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;# Filter specific info&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;config = xml.dom.minidom.parseString(&lt;SPAN&gt;str&lt;/SPAN&gt;(m.get_config(&lt;SPAN&gt;source&lt;/SPAN&gt;=&lt;SPAN&gt;'running'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;filter&lt;/SPAN&gt;=(&lt;SPAN&gt;'xpath'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'/native/router/ospf'&lt;/SPAN&gt;))))&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(config.toprettyxml(&lt;SPAN&gt;indent &lt;/SPAN&gt;= &lt;SPAN&gt;" "&lt;/SPAN&gt;))&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;This returns the OSPF configuration of the device. Thanks again for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 10:52:39 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-sandbox/ncclient-get-cofig-filter-error/m-p/4530724#M7190</guid>
      <dc:creator>kenmartinmiller</dc:creator>
      <dc:date>2022-01-13T10:52:39Z</dc:date>
    </item>
  </channel>
</rss>

