Select to view content in your preferred language

REST API /append is not enabled

904
4
Jump to solution
10-23-2024 06:36 AM
Labels (2)
AntoniGołoś
Emerging Contributor

I am trying to upsert features to a layer in a feature layer using the /append endpoint. Even though the structure of my request is the same as in the documentation, I am getting an error: 

{'error': {'code': 405, 'message': 'Unable to append data.', 'details': ['Append is not enabled.']}}

I am using a token obtained from OAuth2 which is hosted on the same ArcGIS Online as the data. Token is working, because I can make requests to other endpoints like /applyEdits. Append is also enabled, as I can see it from the response from the ArcGIS Online:

"supportsAppend": true

My python code looks like this:

base_url, layer_id, sublayer_id = ... # initialize some values
oauth_session = ... # creates an OAuth2 session - wrapper around requests library
with open("upsert_feature.json", "r") as f:
arcgis_append_features_url = f"{base_url}/arcgis/rest/services/{layer_id}/FeatureServer/{sublayer_id}/append?f=json&upsert=True"
response = oauth_session.post(arcgis_append_features_url, data={"edits": json.loads(f.read())}, headers={"Content-Type": "application/json"})
print(response.json())

Thanks for help!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
mikaël
Frequent Contributor

You need to add the append capability in your service.

Basically you can do it by the API with update definition and just add "Append" to "capabilities" to the service definition or go through the UI on AGOL:

mikal_0-1730216860217.png

 

View solution in original post

4 Replies
CodyPatterson
MVP Regular Contributor
0 Kudos
AntoniGołoś
Emerging Contributor

Thank you for a quick answer! I have seen that post before. I am already using my organization's portal to obtain a token, although not through /generateToken endpoint, just through the /token endpoint. It is important for me to follow the App authentication workflow as the script is part of a service, which does not involve user credentials.

0 Kudos
mikaël
Frequent Contributor

You need to add the append capability in your service.

Basically you can do it by the API with update definition and just add "Append" to "capabilities" to the service definition or go through the UI on AGOL:

mikal_0-1730216860217.png

 

AntoniGołoś
Emerging Contributor

Thank you so much! Now it is working. It was misleading to see the 

"supportsAppend": true

and having to manually add the operation to the list of operations, but now it works 🙂