Hi team,
I am experiencing an issue where the MakeFeatureLayer_management() function. When I run it on my local machine, it returns the feature layer, but when I run the same script on the server it fails. See below:
token = "_____"
url = fr"https://foo.bar.com/server/rest/services/TargetServiceName/FeatureServer/0?token={token}"
layer_name = "Target Service Name"
layer = MakeFeatureLayer_management(url, layer_name).getOutput(0)
ERROR: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset https://foo.bar.com/server/rest/services/TargetServiceName/FeatureServer/0?token=_____ does not exist or is not supported
Failed to execute (MakeFeatureLayer).
I am just trying convert the REST URLs into objects that can be used in arcpy geoprocessing tools and cursors. Does anyone know why this error is occurring or whether there is another way to connect to these endpoints?
Please note that this script is completely ad-hoc - it isn't part of a geoprocessing service or anything like that.
I am running into this same issue. Did you ever solve this?
Well, I just found this:
https://support.esri.com/en-us/bug/the-arcpymakefeaturelayermanagement-function-fails-with-bug-00014...
How are we suppose to run gp tools on feature services? Summarize Within is not accepting just the feature service URL either as I am getting the same error there.
I'm not sure if this will apply to your situation, but I was able to access a service on our portal that is not shared publicly (Owner access only) by signing into the portal first with SignInToPortal—ArcGIS Pro | Documentation
I did not need to add a token query onto the end of the url.
print('Signing into Portal')
arcpy.SignInToPortal(portal_url=<your portal url>,
username=<owner username>,
password=<owner password>)
print('Making feature layer')
arcpy.management.MakeFeatureLayer(in_features=<feature layer url>,
out_layer='FeatureLayer')
Once you have the feature layer created, you can then change versions using Change Version (Data Management)—ArcGIS Pro | Documentation (if needed) or plug the feature layer into other geoprocessing tools.