Add a Column(field) to a feature service layer with Python API

04-11-2024 08:02 AM
Labels (2)
New Contributor

Hello! We have a feature service I would like to add a filed with the python api but I cant seem to figure out what the issue is. Any thoughts?


from arcgis import GIS
from arcgis import features

gis = GIS("https://****************/portal/home/", "****USER*******","******PASS******",  verify_cert=False, trust_env=True)

item = gis.content.get("43c08fc8fb0a4dda9f41f8dc3c202e2b")

layer = item.layers[1]

# Define the update
update_def = {
    'fields': [
        {'name': 'circuit_id',
         'type': 'esriFieldTypeSmallInteger',
         'alias': 'circuit_id',
         'domain': None,
         'editable': True,
         'nullable': True,
         'sqlType': 'sqlTypeInteger',
         'length': 10}

# Update the layer definition
res = layer.manager.add_to_definition(update_def)

# Print the result



I get  the below error. But I am able to see properties of the layer and I am infect connected.

Exception: Unknown Error
(Error Code: 500)


0 Kudos
0 Replies