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

119
0
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)
Reply
0 Kudos
0 Replies