I'm attempting to test some access controls on an ArcGIS Enterprise instance by running a simple script that appends rows from a feature class into a hosted feature service.
In order to ensure schema match, I took one feature class, and published it as a hosted feature service. Then I selected 4 or 5 rows from that same feature class, exported them to a new feature class, changed some things around in the attributes, saved, and then attempted to append those rows. I am not receiving any error from the following code, but none of the rows are updating the hosted feature service.
from arcgis import GIS
import arcpy
import os
url = 'url to my ArcGIS Enterprise instance'
username = 'my username'
pw = 'my pw'
gis = GIS(
url=url,
username=username,
password=pw,
verify_cert=False)
target_layer = gis.content.get('layer id').layers[0]
print(target_layer) #succeeds
#Data I need to append to the feature service layer
fgdb = 'path/to/fgdb.gdb'
append_layer = os.path.join(fgdb, 'append_features')
target_layer.append(append_layer)
print('Local layer appended to service successfully.')
Again, no errors, but nothing committed.
I read into the docs and it seems like I may not be able to append a feature class to the feature service directly - that is fine, I just ran a simple conversion to GeoJSON, editing lines 18-22 like so:
fgdb = 'path/to/fgdb.gdb'
append_layer = os.path.join(fgdb, 'append_features')
outfile = 'path/to/outfile.geojson'
append_feats = arcpy.conversion.FeaturesToJSON(append_layer, outfile, geoJSON='GEOJSON')
target_layer.append(append_feats)
This also succeeded in creating the .geojson file, and returned no errors, but again, no rows were actually committed to the target service layer.
What am I doing wrong, and how do I ensure a meaningful error is reported when a hosted feature layer's .append() action fails?