Open ChrisK9999 opened 4 years ago
Looks like if the feature layer was removed, the feature layer id either returns a NoneType, or a poorly constructed object.
#What is the ID of the Feature Layer you want to download attachments from?
FeatureLayerId = '092d075f4b3a40f78cf1329b20b0d5e7' # this one no longer exists in ArcGIS Online
#What are your ArcGIS Enterprise/ArcGIS Online credentials? This is case sensitive.
PortalUserName = '' # fill these in if Feature Layer ID above is not publicly accessible
PortalPassword = '' # fill these in if Feature Layer ID above is not publicly accessible
PortalUrl = 'https://www.arcgis.com' # fill this in with your org's URL
If that doesn't work, I'd suggest updating your arcgis library. I'm guessing you're using Windows, by the error message.
In command line (cmd.exe), possibly running as administrator:
C:> C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe -m pip install arcgis --upgrade
I ran the script using arcgis v. 1.8.1 and Python 3.6.9, and received the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-358ef73542ab> in <module>
75
76 itemObject = gis.content.get(FeatureLayerId)
---> 77 logger.info('Iterating through layers in Feature Layer "{}"'.format(itemObject.name))
78 display(itemObject)
79
AttributeError: 'NoneType' object has no attribute 'name'
This led me to believe it's an item id that's no longer available.
Line 83 DownloadAttachments.py, It does not seem to like itemObject.layers. I am using Arcgis 1.7.0 and Python 3.6.9. Do you any suggestion to how to go about fixing this without going into the arcgis module.
Line 83: for i in range(len(itemObject.layers)):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis__init.py", line 6978, in getattribute if self['layers'] == None or self['layers'] == []: File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\init.py", line 7009, in getitem return dict.getitem__(self, k) KeyError: 'layers'