Skip to content

FeatureLayerCollection insert_layer() only works if there are no tables present in the Feature Service #2357

@Clubdebambos

Description

@Clubdebambos

Describe the bug
If you have none, one, or multiple feature layers present in a feature service with no table(s) then the insert_layer() method works just fine (although the name parameter is not honored). However, if you have a single table (or more) in your feature service the insert_layer() method will fail.

To Reproduce
Have a feature service with a table(s)

agol = GIS("home")

item = agol.content.get("FS_ITEM_ID")

shp_path = r"C:\Path\to\Zipped_Shapefiles\Shapefile.zip"

flc = FeatureLayerCollection.fromitem(
    item = item
)

#use the flc object insert_layer() method to create a feature layer 
status = flc.manager.insert_layer(
    data_path=shp_path,
    name="County Boundaries Layer" # does not honour
)

print(status)

error:

Traceback (most recent call last):
  File "C:\ArcGISAFP_02\Python_Scripts_Completed\06_Add_Layers_and_Tables\insert_layer.py", line 36, in <module>
    status = flc.manager.insert_layer(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\glenb\Documents\ArcGIS\Clones\arcgispro-clone\Lib\site-packages\arcgis\features\managers.py", line 2527, in insert_layer
    raise e
  File "C:\Users\glenb\Documents\ArcGIS\Clones\arcgispro-clone\Lib\site-packages\arcgis\features\managers.py", line 2497, in insert_layer
    not in orig_item.layers[index].properties["supportedAppendFormats"]
           ~~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
The layer should be inserted whether tables exist or not in the Feature Service

Platform (please complete the following information):

  • OS: Windows 11 Hopme
  • Browser Chrome
  • Python API Version 2.4.1.1

Additional context
Add any other context about the problem here, attachments etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions