Select to view content in your preferred language

Merge FGDB Feature Class with AGOL Hosted Feature Layer

08-12-2021 01:30 PM
MVP Regular Contributor

I'm trying to overwrite a hosted feature layer using a FGDB Feature Class. I've tried a couple things. First, I've tried merging the two.



import arcgis
from arcgis.gis import GIS

gis = GIS('Home')
fl = gis.content.get('item id goes here')
layer_to_merge = r'C:\Users\jpilbeam\Default.gdb\firstdose_test'

arcgis.features.analysis.merge_layers(fl, layer_to_merge)




Exception: Job failed.



2 Using this post as an example, I tried overwriting the hosted feature layer.


import os, sys, arcpy
from arcgis.gis import GIS
source = GIS('Home', verify_cert=False)
layer = source.content.get('itemID goes here')

layer.update({}, r'C:\Users\jpilbeam\Default.gdb\firstdose_test')
layer.publish(overwrite=True, file_type='fileGeodatabase')




Exception: Invalid JSON in 'text' parameter.
(Error Code: 400)


0 Kudos
1 Reply
Occasional Contributor

I have done this in the past with great success.

I used the feature layer collection manager class 


from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

item =  gis.content('itemid')

FLC = FeatureLayerCollection.fromitem(item)

FLC.manager.overwrite('Your file')

File/table/layer /field names have to match.


Hope this helps

0 Kudos