Closed anandak closed 1 year ago
Thanks for reporting this, we will take a look and post any updates
How are you making the append call? What parameters are you defining?
I was able to get it to work with your described workflow. Here is some sample code:
item = gis.content.get(<item_id>)
fl = item.layers[0]
feature_set_dict = {.....} #your feature set dict
feature_set = FeatureSet.from_dict(feature_set_dict)
fc = FeatureCollection.from_featureset(feature_set)
fl.append(upload_format="featureCollection", edits=fc.properties)
@nanaeaubry my apologies, I logged this issue too soon. The root cause was that some properties of the featurecollection like its name were coming from a different configuration settings module and was failing during conversion to JSON. I was able to get append to run successfully.
@nanaeaubry I have run into a strange issue with using append. It fails when there is date field in the feature collection and succeeds if we dont supply a date field in the feature collection. Here is the code you can use to reproduce the issue. You can either create a copy of this feature layer or use my layer as it is anonymously accessible and created only for reproducing this issue purpose.
The code below fails
from arcgis import GIS
from arcgis.features import Feature, FeatureSet, FeatureLayer, FeatureCollection
import uuid
from datetime import datetime
gis = GIS(url="https://www.arcgis.com", username="xx", password="xx")
# this layer is anonymously accessible
layer_url = "https://services1.arcgis.com/DlnuvLGpDczjeSgG/arcgis/rest/services/appendissue/FeatureServer/0"
fl = FeatureLayer(url=layer_url, gis=gis)
pt_geom = {"x":11.5, "y":20.5,"spatialReference": {"wkid":4326}}
pt_attributes = {"appendkeyfield":str(uuid.uuid4()), "nibrs_code":"345", "reported_date": datetime.now()}
feature = Feature(geometry=pt_geom, attributes=pt_attributes)
fs = FeatureSet(features=[feature])
fc = FeatureCollection.from_featureset(fs)
result = fl.append(upload_format='featureCollection',
edits=fc.properties,
upsert=True,
skip_inserts=False,
skip_updates=False,
update_geometry=True,
use_globalids=False,
rollback=True,
upsert_matching_field="appendkeyfield",
return_messages=True)
print(result)
The error message is
But, if you re-run the code after removing the date field in this line,
pt_attributes = {"appendkeyfield":str(uuid.uuid4()), "nibrs_code":"345"
you will see that it succeeds with this message
@anandak Ok we will look at it, thanks for providing sample code!
Hi @nanaeaubry were you able to reproduce the issue? Can you please confirm if my approach is incorrect or if you know of a workaround?
@anandak I was able to reproduce your issue at the current version. However, with the newest release: 2.2.0 it has been fixed.
I would recommend upgrading to this version to avoid having to format on your end (which is the workaround). The pre-release on conda was on Monday and the final release for conda/pip will be on September 25th
@nanaeaubry Thanks, will wait for next release.
Describe the bug While submitting an
featurelayer.append()
request using python api v2.1.0.3, we get an unknown error.To Reproduce Steps to reproduce the behavior:
error: See screenshot below, the featureCollection gets passed as string object name instead of JSON, as seen in fiddler capture
Screenshots
This is the response you get when you try to get status
Expected behavior The featureCollection must be sent as json