AnsweredAssumed Answered

Python API query_related_records() how to?

Question asked by Ben.Sperry_oxitec on Nov 1, 2018
Latest reply on Nov 1, 2018 by Ben.Sperry_oxitec



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[0]


# get the related table of interest
feature_table = feature_layer_collection.tables[0]


# 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)
  • Note:
    The feature layer and table are indeed related 1 to many globalid to parentglobalid


I haven't been able to find a good example to model from. Any help would be appreciated.