Select to view content in your preferred language

Feature Layer edit_features Succeeds but Doesn't Add Attributes

762
2
Jump to solution
03-08-2024 09:04 AM
BenRomlein
Frequent Contributor

I'm trying to use FeatureLayer.edit_feautures(adds=) to add data to a hosted feature layer:

gis = GIS(url='https://my.portal.url/portal', username='my_user', password='my_password')
my_fl = gis.content.search(item_id)[0].layers[0]
row = {"geometry": station_pt,
"attributes": {"Site": station_name}}
update_table = my_fl.edit_features(adds=[row])

with the contents of row being:

{'geometry': {'x': -9692252.2125, 'y': 4674393.7667, 'spatialReference': {'wkid': 102100, 'latestWkid': 3857}}, 'attributes': {'Site': 'Washington_E'}}

The addResults reports success:

{'addResults': [{'success': True, 'objectId': 186}], 'updateResults': [], 'deleteResults': []}

but when I look at the featureLayer, I only see the geometry and not the attribute data.

I saw this post: https://community.esri.com/t5/arcgis-api-for-python-questions/edit-features-says-it-succeeds-but-doe... and I've checked that the Site field in the service details is text, 255:

  • site( modelName: site, nullable: true, editable: true, defaultValue: null, length: 255, alias: Site, type: esriFieldTypeString 

So I'm stumped as to what's going wrong. Any ideas how to make my edits go through?

edit: I should add, the Feature Layer is hosted using ArcGIS Enterprise (Server/Portal/DataStore) 11.2, on Windows.

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

"Site" should be "site". When you update a feature, always use the modelName, as that is the "real" field name. When you add features, you can include all kinds of fields and values, and if those fields aren't present in the destination layer, they're just ignored.

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Esteemed Contributor

"Site" should be "site". When you update a feature, always use the modelName, as that is the "real" field name. When you add features, you can include all kinds of fields and values, and if those fields aren't present in the destination layer, they're just ignored.

- Josh Carlson
Kendall County GIS
BenRomlein
Frequent Contributor

That works! Thank you for your help.

0 Kudos