Append() takes no keyword arguments

02-12-2021 08:56 AM
New Contributor III

I'm pretty new to the ArcGIS API for Python. I'm trying to use the Append function to append data from a source file geodatabase that is hosted on AGO to a target feature layer. I'm using the upsert parameter because, not only am I adding additional features to the target from the source, but I've also changed some of the attributes within the source and I want those changes reflected in the target.

What I'm trying to do is pretty basic I think, but when I run my script I get the message "append() takes no keyword arguments". 

Here's my code:

import os

from arcgis.gis import GIS

# Create a GIS connection to AGO where the test data is located
gis = GIS(url, username, password)

# Target feature layer (feature layer with fewer points that needs to be updated)
target_item = gis.content.get("1fbf6a4e1ebe4720aa7036a3d52f7544")
print("feature layer to update:", target_item)
target_lyr = target_item.layers

# Look for the unique field within the target layer
# simply verifies that I had a field with unique values in my target layer
uk_flds = (f.fields for f in target_lyr[0].properties.indexes if f.isUnique)
for fld in target_lyr[0].properties.fields:
    if in uk_flds:

# Source fgdb
src_lyr ="Water_system_valves_source")[0]

# Run the Append function
    append_fields=["FID", "VALVETYPE", "Creator"],


The field with unique values that matches records between the two layers is "FID." I specified "FID", "VALVETYPE", and "Creator" in the append_fields parameter because VALVETYPE and Creator are the two fields where attribute values were changed in the source dataset. FID was specified because it is the unique identifier (I'm not sure if this is correct, but it's what I took away from some of the documentation). All of the fields are the same between the source and target layers, but they're in a slightly different order.

I primarily followed this resource: (starting at the "Insert New Features and Update Existing Features - Upsert" section).

Any assistance would be appreciated. Thank you.

Tags (2)
4 Replies
MVP Frequent Contributor

I've not utilised this before, but if you're appending to a specific layer, wouldn't you need to reference an individual layer e.g.

target_lyr = target_item.layers[0]


New Contributor III

Thank you David, you were right that I needed to alter the code to read:

target_lyr = target_item.layers[0]

I'm now getting an error of "Object reference not set to an instance of an object". My understanding is that this might be a field mappings issue between the source and target layers. I'm going to look into this a bit more and post any solution I find.

I believe that my fields are identical between the two layers, but I need to inspect it further.

New Contributor II

@pmccord did you get this working? I am running into the same error and am wondering if you found a solution.

New Contributor III

@JoeWaters1 , I ultimately decided to run the Append tool from ArcGIS Pro on my AGO layers. The work I was doing didn't require using the Python API, so using the Append tool from Pro worked as an alternative for me.