I added fields to a Feature Layer and now there are problems with adding Features to this. So I would like to ask, how can I solve this issue?
This is my actual workflow:
I have a Feature Service with a Feature Layer and I want to join this with the structure and data into another Feature Service which has already some Feature Layers. An empty feature
1. I get the necessary information for the new Feature Layer form the existing one (fields, geometry type and name). This information is stored in a dictionary with the correct key as they are required in the layer description. The "Shape_length", "Shape_area" and "FID" fields are removed.
dictLayer = {}
dictLayer["fields"] = existingLayer.properties["fields"]
dictLayer["geometryType"] = existingLayer.properties["geometryType"]
dictLayer["name"] = existingLayer.properties["name"]
2. The dictionary is appended to a list and a dictionary is built out of this. This dictionary is used to update the layer's definition. This works very well and the layer with the fields occures in ArcGIS Online.
layersList = []
layersList.append(dictLayer)
dictUpdate = {"layers" : layersList }
newFeatureLayerCollection.manager.add_to_definition(dictUpdate)
3. The features that should be added to the layer are converted into a FeatureSet. Now there are many Features that should be added to the Feature Layer in one list. This meets the requirements of the "edit_features()" method. So this method is called with the Feature Set as parameter
layerEdit.edit_features(adds = fset)
When this function is executed this error message occures:
The given key was not present in the dictionary.
---------------------------------------------------------------------------RuntimeError Traceback (most recent call last)<ipython-input-35-f124a193606a> in <module>()----> 1 layerEdit.edit_features(adds = fset)~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\features\layer.py in edit_features(self, adds, updates, deletes, gdb_version, use_global_ids, rollback_on_failure) 943 print("Parameters not valid for edit_features") 944 return None--> 945 return self._con.post(path=edit_url, postdata=params, token=self._token) 946 947 # ----------------------------------------------------------------------~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\_impl\connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers) 1151 verify_cert=verify_cert, is_retry=True) 1152 -> 1153 self._handle_json_error(resp_json['error'], errorcode) 1154 return None 1155 except AttributeError:~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\_impl\connection.py in _handle_json_error(self, error, errorcode) 1171 1172 errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"-> 1173 raise RuntimeError(errormessage) 1174 1175 class _StrictURLopener(request.FancyURLopener):RuntimeError: The given key was not present in the dictionary. (Error Code: 500)
It seams to me as there is a problem with the geometry. Because i get a query result with all Features and attributes but there is no information about Shape_Area and Shape_Length.
When I swith to the "Data" tab in ArcGIS Online there is a number of Features but no entry in the Table view.
This is the URL to the Service of this example: https://services1.arcgis.com/wdMHWK8xfn32LjIy/arcgis/rest/services/CombineLayers/FeatureServer
What is the reason for this problem?