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!