Hello - I am trying to append one feature layer to another in ArcGIS Online using the ArcGIS API for Python. Code below. I am receiving the error: RuntimeError: Object reference not set to an instance of an object.
(Error Code: 400)
well, your flayer is undeclared!
To clarify the proper workflow of what you are trying to do:
1. First get the hosted feature service containing the layer you want to update/append, like this FS=gis.content.get('itemID here')
2. Get the layer like this FL=FS or whatever index/name you have
3. Get the item id of the AGOL item containing source data (could be a shapefile or whatever you have previously uploaded. I am assuming a geojson file) agolId=gis.content.get('itemID here')
4. Now attempt to append like this: ret=FL.append(item_id=agolId, upsert=false, update_geometry=true, upload_format='geojson')
5. Optionally you should check the ret variable to see if success or failire
Finally, fields should match between source and dest. If not, you can make use of the field_mappings prop of the append method
Good luck and check append doc below
a featurecollection would be the closest to your case.
look at the upload_format of the append method.
You would need to get a featurecollection out of one of the layers of your hosted feature service
If you run into any issues let me know and I’ll write a working code for you but tomorrow because it’s a bit late where I am