I have a feature layer containing points. I have a related table that has a multiple records for each point feature.
How can I query and use the data from the related records?
From the python API documentation I wrote the following in Jupyter Notebook:
# get the feature layer collection from AGOL
feature_layer_collection = gis.content.get('08d12e0*****4379bd5881f26539838e')
# get the feature layer of interest
feature_layer = feature_layer_collection.layers
# get the related table of interest
feature_table = feature_layer_collection.tables
# query the related records from feature_table
# I am using the "objectid" field and "globalid" field from feature_layer
related_query = feature_layer.query_related_records(object_ids='objectid', relationship_id='globalid')
I get the error:
RuntimeError: Unable to perform query. Please check your parameters. (Error Code: 400)
I haven't been able to find a good example to model from. Any help would be appreciated.
So I figured it out by reading the REST API documentation Query Related Records (Feature Service)—ArcGIS REST API: Services Directory | ArcGIS for Developers
Just in case anyone is as baffled as I was:
the object ID it is asking for is that actual object ID of the source feature
the relationship id is an identifier you can find by looking at the service page under "Relationships:"