Disable deleting features while maintaining create and update in a referenced service

2022
3
Jump to solution
11-26-2021 01:34 AM
Labels (2)
Clubdebambos
Occasional Contributor III

When you host a feature service in Portal you can go to settings and turn on/off if features can be deleted (see below)

 hosted_editing.JPG

This option does not exist when the data is referenced from a registered sde geodatabase. When publishing from ArcGIS Pro there is no option for this either, I seem to recall there was in ArcMap where you could select using check boxes. I do not have access to ArcMap and required to publish via ArcGIS Pro.

arcgis_pro_options.JPG

I need to prevent users from deleting features and leave them with the ability to only edit current features and add new features. The data cannot be hosted and must be via a registered sde geodatabase.

I have exported the JSON of the service and can see that all capabilities are turned on.

"capabilities": "Query,Create,Update,Delete,Uploads,Editing,Sync,Extract"

I need to remove the Delete capability.

I have tried to update the capabilities using the Python API with the code below.

import json
from arcgis import GIS
from arcgis.features import FeatureLayer

## connect to Portal
conn = GIS(url="https://url/portal/home", username="username", password="password")

## access the fs via its id
item = conn.content.get('****')

## get the definition json
with open(r"path\to\update_test.json") as json_data:
    data = json.load(json_data)

## access the FeatureLayer components of the item
layer = FeatureLayer(item.url)
## update based on the json
layer.manager.update_definition(data)

 

I get the error...

Exception: Access to admin resources are not allowed
(Error Code: 403)

 

The JSON file has the following

{
    "capabilities": "Query,Create,Update,Uploads,Editing,Sync,Extract"
}

 

I have tested this on a hosted feature service and it works fine. So what is preventing me doing it on a referenced feature service with data published from a registered database? Any help appreciated. 

~ learn.finaldraftmapping.com
0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Notable Contributor

For non-hosted services, you'd manage the capabilities via Server Manager:

JonathanQuinn_1-1638215036285.png

 

 

View solution in original post

3 Replies
JonathanQuinn
Esri Notable Contributor

For non-hosted services, you'd manage the capabilities via Server Manager:

JonathanQuinn_1-1638215036285.png

 

 

Clubdebambos
Occasional Contributor III

Thank you @JonathanQuinn 

I had actually gone in there to try that and couldn't see the option to do that. But your screenshot showed me that I needed to highlight the Feature Access component.capabilities.JPG

Which then opens up those capabilities.

capabilities_2.JPG

Thank you.

~ learn.finaldraftmapping.com
0 Kudos
feralcatcolonist_old
Occasional Contributor II

Hi @JonathanQuinn, are you saying that those capabilities are not accessible via the ArcGIS API for Python?

I am trying to programmatically change a bunch of services to enable sync, launched via bulk publish from an Enterprise Datastore Item. I have not yet been successful after trying a few routes.

I've tried to access the FeatureLayer.manager and have received the same error. I don't quite understand it because I'm utilizing the admin_url found at the: portaladmin/federation/servers location

Access to admin resources are not allowed

(Error Code: 403)

I've also tried accessing the datastore.publish_layers but am a bit confused about the correct structuring of the service configuration template (srv_config). I have a Github issue open as well with regard to documentation: https://github.com/Esri/arcgis-python-api/issues/1227

Publish layes failed.
Invalid value for serverFolder. Layers have been published from this data store before and the value is read-only. Passing null is valid.
(Error Code: 400)


Likes an array of [cats, gardening, photography]
0 Kudos