I currently using the ArcGIS API for python to relate create a hosted table and feature layer. I am trying to relate the two with 2 one to many relationships using the API. I am making use of the manager.update_definition function, passing in "relationships" attributes similar to this:
For reference, I was attempting to follow this guideline https://community.esri.com/t5/arcgis-api-for-python-blog/add-table-from-hosted-service-to-another-an...
**UPDATE: There seems to be a bug with using the ArcGIS API for Python to add a relationship when using Portal (works fine in ArcGIS Online) for Hosted Feature Services. See here.
Hi @StephenAsamoah,
I wrote that guide. It seems the construction of your relationship dictionary is causing the problem, see notes below.
relationship = {
"id": 0, # this is an integer, the id will also be the same in the related relationship dictionary
"name": "Layer_to_Table",
"relatedTableId": 0, # this is an integer representing the id in the layer/table url
"cardinality": "OneToOne", # esriRelCardinalityOneToOne or esriRelCardinalityOneToMany
"role": "esriRelRoleOrigin",
"keyField": table.properties.serviceItemId, # a field name from the origin layer/table
"relatedKeyField": "table_id", # not required
"composite": True
}
All the best,
Glen