<?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: Python code not continuing when using try / continue in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/python-code-not-continuing-when-using-try-continue/m-p/5429659#M4872</link>
    <description>&lt;P&gt;Sorry I resolved it, needed to move the looping though networks out side the "try" as it was failing on one network and ending the loop, using "try" after the "for net in networks:" and it works as expected&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 00:07:28 GMT</pubDate>
    <dc:creator>DevilWAH1</dc:creator>
    <dc:date>2023-02-24T00:07:28Z</dc:date>
    <item>
      <title>Python code not continuing when using try / continue</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-code-not-continuing-when-using-try-continue/m-p/5429658#M4871</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;I have the following code that I am trying to test, when some error happen it continues as expected I know some of the net works it will loop through are not wireless but rather than check each i &lt;SPAN&gt;just&lt;/SPAN&gt; want to try and if it fails continue. But when i run it i get the below error and it stops? &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So to be clear i know why the call is failing and i expect that. But &lt;/SPAN&gt;&lt;SPAN&gt;it is hitting the try: block, but rather than continue it stops the script? Why is this, other errors it continues with, is the the python &lt;SPAN&gt;library&lt;/SPAN&gt; breaking out of the script and how can I over ride it. Yes i could always check that the network has wireless type but the "try" method would be nice to use. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;ERROR&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;wireless, getNetworkWirelessSsids - 400 Bad Request, {'errors': ['This endpoint only supports wireless networks']}&lt;BR /&gt;Meraki API error: wireless, getNetworkWirelessSsids - 400 Bad Request, {'errors': ['This endpoint only supports wireless networks']}&lt;BR /&gt;status code = 400&lt;BR /&gt;reason = Bad Request&lt;BR /&gt;error = {'errors': ['This endpoint only supports wireless networks']}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;SCRIPT&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;     try:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            for net in networks:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                print (f'Checking network:  {net["name"]}')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                ssids = dashboard.wireless.getNetworkWirelessSsids(net["id"])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                ssid = next((item for item in ssids if item["name"] == "WSP Corporate"),None)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                ccount = dashboard.wireless.getNetworkWirelessClientCountHistory(net["id"], ssid=ssid["number"], timespan=86400)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                cfailed = dashboard.wireless.getNetworkWirelessFailedConnections(net["id"],ssid=ssid["number"], timespan=86400)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                #last step is to out put the details to a csv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                for item in cfailed:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                    #print (item["clientMac"] + "   " + item["serial"]+ "    " + item["failureStep"]+ "    " + item["type"] + "     " + item["ts"])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                    csvdata = (net["name"],ssid["name"],item["clientMac"],item["serial"],item["failureStep"],item["type"],item["ts"])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;                    writer.writerow(csvdata)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;        except meraki.APIError as e:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            print(f'Meraki API error: {e}')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            print(f'status code = {e.status}')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            print(f'reason = {e.reason}')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            print(f'error = {e.message}')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            csvdata = (net["name"],"ERROR","ERROR","ERROR","ERROR","ERROR","ERROR")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            writer.writerow(csvdata)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            continue&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;        except Exception as e:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            csvdata = (net["name"],"ERROR","ERROR","ERROR","ERROR","ERROR","ERROR")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            writer.writerow(csvdata)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;            continue&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Feb 2023 23:59:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-code-not-continuing-when-using-try-continue/m-p/5429658#M4871</guid>
      <dc:creator>DevilWAH1</dc:creator>
      <dc:date>2023-02-23T23:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python code not continuing when using try / continue</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-code-not-continuing-when-using-try-continue/m-p/5429659#M4872</link>
      <description>&lt;P&gt;Sorry I resolved it, needed to move the looping though networks out side the "try" as it was failing on one network and ending the loop, using "try" after the "for net in networks:" and it works as expected&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 00:07:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-code-not-continuing-when-using-try-continue/m-p/5429659#M4872</guid>
      <dc:creator>DevilWAH1</dc:creator>
      <dc:date>2023-02-24T00:07:28Z</dc:date>
    </item>
  </channel>
</rss>

