Deleting ArcGIS Online item - does not exist or is inaccessible

05-21-2019 01:05 PM
New Contributor III

I use a Python script to export an item to a FGDB, download said FGDB and then delete it. The script successfully deletes the FGDB, but when I go to the AGOL account, it is still there, and I am unable to remove it. When I try to delete the item I get:

And when I try to view the item in AGOL, I get:

Below is my script (some of which I got from another user on this forum, but I can't find the thread):

from arcgis.gis import GIS
from datetime import datetime
from pathlib import Path
from zipfile import ZipFile
import time, os, zipfile

gis = GIS(site,user,pw)
print('Logged on...\n')

fs = gis.content.get('XXXXXXXXXXXXXXXXXXXXXXX')
print(f'Exporting Feature Service to FGDB - {}')
fs.export('_temp','File Geodatabase',parameters=None,wait='True')

# search for fgdb and get item id
while True:
        print('Locating FGDB')
        search_fgb ='_temp')
        fgb_item_id = search_fgb[0].id
        fgdb = gis.content.get(fgb_item_id)
    except IndexError as e:
        print('FGDB does not exist yet')

data_path = Path('./monthlyDownload')

if not data_path.exists():

print('Downloading FGDB')

'''while statement runs until a valid zipped file is created'''
## randomly the output is a 1 KB file that is not a valid zipped file.
## The while statement forces a valid zipped file to be created.
print('Finalizing zip file')
zipfullpath=os.path.join(data_path,"")#full path to the zipped file once it is downloaded to your computer
while zipfile.is_zipfile(zipfullpath)==False:

# delete temp FGDB in AGOL
print('Deleting temporary FGDB')
while True:
    except RuntimeError:

0 Kudos
2 Replies
Occasional Contributor II


Have you tried clearing your cache or running your browser in incognito mode to see if its a cache issue? Also please try re-signing in to your ArcGIS Online organization account. Hope that works!

0 Kudos
New Contributor III

This sadly didn't work. I cleared the cache, logged in and out, and tried the same in incognito mode. Maybe I'm calling the fgdb.delete(function too soon. Perhaps if I created a list of FGDBs deleted, and then called a function to delete all those FGDBs that would work. Just spit-balling. 

0 Kudos