Hi,
Using the ArcGIS Pro 3.1 python library, I am trying to append data to a survey123 hosted feature service in ArcGIS Enterprise 10.9.1, .
The file geodatabase that I am trying to append has the exact same attributes as the hosted feature service. There is no GlobalID field in the file Geodatabase and it is not necessary for any relations afterwards. It is sufficient that the globalID is added once it the data is appended to the survey123 hosted feature service.
# Import necessary modules
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection, FeatureLayer
import arcpy, sys
# Get input parameters
# Make GIS connection
gis = GIS(<portalURL>, "", "")
# Get survey123 Feature Service
surveyItem = gis.content.get(portalId)
fs = FeatureLayerCollection.fromitem(surveyItem)
# Get layer within survey123 feature service
lyr = FeatureLayer(fs.layers[0])
# get input features
inputFeatures = <input file geodatabase path>
# Update features in the feature layer
result = lyr.append(source_table_name = inputFeatures, upload_format = "filegdb")
# Print the result
arcpy.AddMessage(result)
When running the above script, the hosted feature service can correctly be found. I do get, however, the following error:
raceback (most recent call last):
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16931, in _hydrate
self._refresh()
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16905, in _refresh
raise e
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16894, in _refresh
dictdata = self._con.post(
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 1372, in post
if url.find("://") == -1:
AttributeError: 'FeatureLayer' object has no attribute 'find'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 34, in <module>
result = lyr.append(source_table_name = inputFeatures, upload_format = "filegdb")
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py", line 2785, in append
if self.properties.supportsAppend == False:
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16954, in _hydrate
self._refresh()
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16905, in _refresh
raise e
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 16894, in _refresh
dictdata = self._con.post(
File "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 1372, in post
if url.find("://") == -1:
AttributeError: 'FeatureLayer' object has no attribute 'find'
I don't understand the cause of this error. Can aybody help me or know how I can append a file geodatabase to a survey123 hosted feature service using python?
best,
Jelle Stuurman