We are trying to insert rows into a many to many relationship table via arcpy script. Attempting to write new rows with insertcursor causes an error. Manually adding data to relationship table works fine.
RuntimeError: Message: Unable to complete operation.
Details: Internal error during object insert. Invalid foreign key value
We have checked the following things-
Below is the sample snippet of code-
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.activeMap
mc_guid = '{0196282F-17E7-4A29-A2E4-0B381C407A30}'
ls_guid = '{5FB63569-5792-42H7-AAA9-3E7A912F3226}'
lsmc_rel = m.listTables("R_Table1_Table2)[0]
with arcpy.da.InsertCursor(lsmc_rel, ['T1_GlobalID', 'T2_GlobalID']) as cursor:
cursor.insertRow((mc_guid, ls_guid))
Version details-
Enterprise Version- 11.5
ArcGIS Pro- 3.5
Solved! Go to Solution.
This error was found and there's no proper solution for it yet.
160271: Invalid foreign key value | ArcGIS Pro documentation
We've tried ArcGIS API for Python instead of Arcpy for editing features and it worked-
print(result)
This error was found and there's no proper solution for it yet.
160271: Invalid foreign key value | ArcGIS Pro documentation
We've tried ArcGIS API for Python instead of Arcpy for editing features and it worked-
print(result)