Merge FGDB Feature Class with AGOL Hosted Feature Layer

303
1
08-12-2021 01:30 PM
JaredPilbeam2
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.

1

 

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)

 

 Result:

 

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')

 

 Result:

 

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

 

0 Kudos
1 Reply
PeterMilenkovic
New Contributor III

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')

 

 

https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html#arcgis.features.man...

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

 

Hope this helps

0 Kudos