cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
61
Views
0
Helpful
4
Replies

Python - API Error - 404 Not Found, b' '

NJNetworkGuy100
Level 3
Level 3

Starting to get this more and more in a script we've been using for over a year (it uses a few CSV files to build a new network in the dashboard with all the standard settings).

The problem started in the function that updates the info for devices in a network.

NJNetworkGuy100_0-1786455996764.png

Then, if it gets through the UpdateDevice API calls without an issue, I randomly get the error again in the function that updates the WAN IP info on the MX.

NJNetworkGuy100_1-1786456030282.png

This is the code for updating the Device Info...the data is pulled in from a CSV file and the various data is entered into a list of dictionary objects, which is then used in this function.  Nothing crazy.  I've checked the CSV file in Notepad++, and the data looks good to me.  

NJNetworkGuy100_2-1786456132181.png

These aren't the first API calls in the script...the claimNetworkDevices and createOrganizationNetwork are two API calls that have no issues and are called before these API calls.

Any advice or help would be appreciated.  

 

4 Replies 4

balaji.bandi
Hall of Fame
Hall of Fame

It was not clear at what stage it was failing.

Does this 404 crash happen on the very first device in the loop, or does it happen randomly on a device in the middle of the list?

If you run the len (serialNum)  print statement, what is the exact character count returned for the failing device?

I take that you can reach the API 

 

https://developer.cisco.com/meraki/api-v1/errors/

BB

=====️ Preenayamo Vasudevam ️=====

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

So, it can happen randomly in the loop....

I tested this morning, and it gave that 404 error to the first device a few times.  Then randomly, when running the script again, the first device made the UpdateDevice API call just fine, and the second device failed with the same error.  And then randomly a few times later, it got through all the devices just fine, and failed on the WAN IP Update API call (which is the next function in the script). 

The script always connects to the Dashboard fine, and runs a few API calls without issue before I get these 404 errors (getOrgNetworks, claimNetworkDevices, createOrgNetwork, to name a few).  

NJNetworkGuy100
Level 3
Level 3

Well, shoot.  It looks like I needed to add a decent "pause" to my script before making updates to devices that were just claimed in a network.  

Just added a time.sleep(15) function immediately AFTER the claimNetworkDevices API call (and before any other API call after that).  I don't know if the pause needs to be 15 seconds, but that seems a safe amount of time.  

That seems to have solved the issue...I'm going to keep testing, but it may just be as simple as the Meraki dashboard needing time to process the change in status of the devices (unclaimed to claimed).

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

If the devices are being added to a brand-new network, the network may not be available immediately after creation.

What you could do is introduce a loop to query the network and see if you can find it, and if not, do a short pause and retry - and then start the process to add the devices.

I think you are pretty unlucky.  Networks tend to become available very quickly after they are created.