Overwriting Hosted FeatureTable with Python API does not work (API v. 1.8.2) in ArcGIS Enterprise

266
3
12-04-2020 09:32 AM
Jay_Gregory
Occasional Contributor III

I have created a hosted feature table (no location information) from a CSV in my 10.8.1 Portal.  Trying to programmatically update this keeps throwing an error:

 

 

feature_table_item = Item(GIS, itemId) #this points to a hosted feature table
flayer_collection = FeatureLayerCollection.fromitem(feature_table_item)
flayer_collection.manager.overwrite(path_to_csv)

 

The error is 

 

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-25-263240bbee7e> in <module>
----> 1 main()

<ipython-input-24-7c9cf54f40f6> in main()
      8     if IsNewData(csv, cdcili):
      9         print('loading')
---> 10         load(csv, cdcili)
     11         #UpdateCovidDashboard("CDC ILI Data")
     12         #mail("CDC ILI finished at {}".format(datetime.datetime.now()),"CDC ILI Success", getEmailsFromFile(__file__, 'emails.txt'))

<ipython-input-18-6d8668ce2733> in load(csv, cdcili)
     72 def load(csv, cdcili):
     73     cdc_flayer_collection = FeatureLayerCollection.fromitem(cdcili)
---> 74     return cdc_flayer_collection.manager.overwrite(csv)

~\AppData\Local\ESRI\conda\envs\EIM\lib\site-packages\arcgis\features\managers.py in overwrite(self, data_file)
   1361                 "useDescription" : "on"
   1362             }
-> 1363             lyr_url_info = "%s/layers" % feature_layer_item.layers[0].container._url
   1364             fs_url = "%s" % feature_layer_item.layers[0].container._url
   1365             layer_info = self._gis._con.get(lyr_url_info, {'f' : 'json'})

IndexError: list index out of range

 

 

I can see that is looking for the first item in the layers attribute. 

However, flayer_collection.layers is an empty array, which explains the IndexError

flayer_collection.tables however is an array with one table item: 

[<Table url:"https://MyGISServer/arcgis/rest/services/Hosted/MyTable/FeatureServer/0">]

So why does the update method only call on the layers attributes instead of whichever attribute (layers or table) contains the service URL.  Ostensibly a hosted feature layer / table will only have ONE service anyway (as opposed to a MapService).  Is there an accepted workaround here or am I missing something? 

Tags (4)
0 Kudos
3 Replies
BrianKaplan2
Occasional Contributor

I have this problem with Server/Enterprise too and get the same error "IndexError: list index out of range".    It works with ArcGIS Online.  Jay, did you figure this out.    Its a little maddening or troublesome that it works with ArcGIS Online and note Enterprise and no one responded to you.

0 Kudos
Jay_Gregory
Occasional Contributor III

I think I raised a case with Esri and they logged it as a bug:

https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEzNjI2MA==

My workaround was using feature classes and getting the geometry to 0,0 for every record.  Was only using the data for dashboard widgets .

0 Kudos
BrianKaplan2
Occasional Contributor

Thanks for the info on the bug and your work around. I had the problem in Server/Enterprise 10.7.1.  We are upgrading to 10.8.1 and hope the bug is fixed in it.  

0 Kudos