Select to view content in your preferred language

Syntax for layer_mappings parameter in FeatureLayer.append

188
5
a week ago
oregonparksgis
Occasional Contributor

I can't seem to find the correct syntax for the layer_mappings parameter of append. I checked the API reference and I've got the argument name right, however, the line below throws  TypeError: append() got an unexpected keyword argument 'layer_mappings'

fLyr.append(fgd_item, upload_format="featureService", layer_mappings=[{"id": 3, "sourceId": 0}])

 

I also checked the REST API syntax too but that didn't seem to help. Anyone used this parameter before?

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

curious, since the syntax in your link shows

layerMappings=[{“id”: <layerID>, “sourceId”: <layer id>}]


... sort of retired...
0 Kudos
oregonparksgis
Occasional Contributor

Yeah I can't figure it out, since the help shows both

Screenshot 2025-07-17 180038.png

 

I've tried that other way as well and get the same TypeError: append() got an unexpected keyword argument 'layerMappings'

fLyr.append(fgd_item, upload_format="featureService", layerMappings=[{"id": 3, "sourceId": 0}])

 

0 Kudos
Clubdebambos
MVP Regular Contributor

Hi @oregonparksgis,

I see you are using upload_format="featureService", is this correct since your item_id parameter is fgd_item, are you attempting to append from a File Geodatabase? If so change to upload_format="filegdb".

You then use the source_table_name parameter to get the data from the source feature class in the gdb and append to the feature layer. You can only do one layer at a time from a gdb, but you could use a for loop to do all your layers with a single script.

You might be getting the error: TypeError: append() got an unexpected keyword argument 'layer_mappings' because it is detecting a gdb rather than a feature service and the layer_mappings parameter is only available when appending from a Feature Service to Feature Service and not from File Geodatabase to Feature (Layer) Service.

On the other hand, if your source is indeed a Feature Service, then I am at a loss 😅

All the best,

Glen

 

~ learn.finaldraftmapping.com
0 Kudos
oregonparksgis
Occasional Contributor

Thanks @Clubdebambos,

Unfortunately I am indeed trying to update using a Feature Service after all attempts to use an fgdb that is an existing item in agol have failed. The variable name in my code snip is an artifact of those attempts.

In the Feature Service case, manually entering the parameters from the REST endpoint interface works fine.

https://services.arcgis.com/********/ArcGIS/rest/services/******/FeatureServer/3/append?token=******

Screenshot 2025-07-21 072312.png

Screenshot 2025-07-21 072507.png

Screenshot 2025-07-21 072752.png

So the issue appears to me to just be the python syntax. I've opened a support ticket so we'll see if that gets it resolved.

Clubdebambos
MVP Regular Contributor

Went to Kudo on my phone and accidentally hit accept as solution! Ah well 🤣

~ learn.finaldraftmapping.com
0 Kudos