Select to view content in your preferred language

relate a hosted table and feature layer arcgis

287
1
05-28-2024 12:11 PM
Labels (1)
StephenAsamoah
New Contributor

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:

response = layer.manager.update_definition({"relationships": [relationship]})
 
layer is a feature layer taken from: layer = FeatureLayer(url, gis = gis)
relationship is an object of the form relationship = {
            "id": layer.properties.serviceItemId,
            "name": "Layer_to_Table",
            "relatedTableId": layer.properties.serviceItemId,
            "cardinality": "OneToOne",
            "role": "esriRelRoleOrigin",
            "keyField": table.properties.serviceItemId,
            "relatedKeyField": "table_id",
            "composite": True
        }
 
This always seems to fail throwing a 500 error code that says "Field 'relationships" cannot be updated. I know the response object is supposed to give an indication as to if the operation was successful or not (and the reason) but it doesn't even get to that point to potentially see what the issue is. Any ideas what the potential issue could be, and if I'm even using the correct approach. 
If not, what would the correct approach be.
 
Thanks
0 Kudos
1 Reply
StephenAsamoah
New Contributor
0 Kudos