This is supposed to be simple but running into issues attempting to submit updates to a feature service layer. Forever I have simply used the REST api (ie. "applyEdits") on a service layer and always works as expected but now I'm converting some of that code over to the python API to work directly on the portal items themselves.
Anyway, this is somewhat close to THIS example but getting this error "object of type 'Feature' has no len()" on the edit_features() method.
#set layer
portalItem = gis.content.get('9cb6469e3d3e43379551abbb1b74a284')
for layer in portalItem.layers:
if "Final" in layer.properties.name:
#check if there is a matching appId
checkSet = layer.query(where='objectid={}'.format(oid), return_count_only=True)
if checkSet == 1:
#get the row to edit using the oid value
fset = layer.query(where='objectid={}'.format(oid))
editFeature = [f for f in fset.features if f.attributes['OBJECTID']==oid][0]
editFeature.attributes['PERMIT_ID'] = inputPermitId
editFeature.attributes['PERMIT_NO'] = inputPermitId
edit_result = layer.edit_features(updates=editFeature)
Solved! Go to Solution.
Oh. the updates parameter is supposed to be a list in edit_features() method:
edit_result = layer.edit_features(updates=[editFeature])
Oh. the updates parameter is supposed to be a list in edit_features() method:
edit_result = layer.edit_features(updates=[editFeature])