Hi I encounter a problem for deleting a user with API
My code :
reponse code :
Admins, deleteOrganizationAdmin - 404 Not Found,
Traceback (most recent call last):
File "delete_user.py", line 34, in <module>
dashboard.admins.deleteOrganizationAdmin(MY_ORG, id_user)
File "C:\Program Files (x86)\Python 3\lib\site-packages\meraki\api\admins.py", line 97, in deleteOrganizationAdmin
return self._session.delete(metadata, resource)
File "C:\Program Files (x86)\Python 3\lib\site-packages\meraki\rest_session.py", line 232, in delete
self.request(metadata, 'DELETE', url)
File "C:\Program Files (x86)\Python 3\lib\site-packages\meraki\rest_session.py", line 153, in request
raise APIError(metadata, response)
meraki.exceptions.APIError: Admins, deleteOrganizationAdmin - 404 Not Found,
C:\inetpub\wwwroot\merakidevops\script\Admin creation\Create Agent V3.0\Move and change\Delete>pause
You're getting a 404, which means bad URL - resource not found.
Are you able to run dashboard.organizations.getOrganizations() using the same parameters?
What happens if you remove base_url?
If I remove the base URL i have the same error (i have multiple script who have this base url and they work with no problem)
The GetOrganization work
@damienleick wrote:
If I remove the base URL i have the same error (i have multiple script who have this base url and they work with no problem)
The GetOrganization work
Okay cool, so the base works. That makes life easier!
Here's how I'd tshoot this:
What if you do a try-except like:
with open('user_delete.csv', 'r') as csvfile:
users = csv.reader(csvfile, delimiter=',')
next(users)
for id_user in users:
try:
dashboard.admins.deleteOrganizationAdmin(MY_ORG, id_user)
except:
print(f"No admin {id_user} found.")
If that works, do go back and clean up that except so it's not a blanket exception... This is quick and dirty.
Where did you get the id_user values from?
From the .csv file which he is reading
@Edgar-VO wrote:From the .csv file which he is reading
Okay, where did you get the data that you've put into the CSV file?