Tony,
I have verified my connection to Enterprise Portal and followed your code example exactly.
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
try:
# Connect to Enterprise Portal
gis = GIS("https://MyEnterprise/portal", "Username", 'Password', verify_cert=False)
print(f"Connected to: {gis.properties.portalName}")
print(f"Logged in as: {gis.users.me.username}")
# Update service capabilities
service_url = "https://MyEnterprise/server/rest/services/FolderName/ServiceName/FeatureServer/"
flc = FeatureLayerCollection(service_url, gis=gis)
print(flc.properties)
flc.manager.update_definition({
"hasStaticData": False,
"capabilities": "Query,Create,Update,Delete,Editing,ChangeTracking,Append"
})
print("Service capabilities updated successfully")
To the same result,
Error: {'code': 500, 'message': "Service 'ServiceName'.'FeatureServer' does not exist in folder 'FolderName'.", 'details': []}
I've tested it with multiple service URL's to the same result. I added in the print(flc.properties) to verify that my connection works and that I can see the properties of my sercive, and it sucessfully lists out all the properties.
The username and password is the account that owns the portal data store used to publish the layers in bulk, and it has the max permissions it can be given in Portal. I've also been able to the following code to verify that all the services I want to update are in the correct folder, and it also returns everything sucessfully.
gis = GIS("https://MyEnterprise/portal", "Username", 'Password', verify_cert=False)
user = gis.users.get("Username")
folder_items = user.items("FolderName",max_items=1000)
for item in folder_items:
print(f"Item Title: {item.title}, Item Type: {item.type}, Item ID: {item.id}, Item URL: {item.url}")
If it is a privileges issue, I'm not sure what needs to be updated.