<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python API query_related_records() how to? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-related-records-how-to/m-p/876547#M4929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a feature layer containing points. I have a related table that has a multiple records for each point feature.&lt;/P&gt;&lt;P&gt;How can I query and use the data from the related records?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the python API documentation I wrote the following in Jupyter Notebook:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# get the feature layer collection from AGOL&lt;BR /&gt;feature_layer_collection = gis.content.get('08d12e0*****4379bd5881f26539838e')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get the feature layer of interest&lt;BR /&gt;feature_layer = feature_layer_collection.layers[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get the related table of interest&lt;BR /&gt;feature_table = feature_layer_collection.tables[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# query the related records from feature_table&lt;BR /&gt;# I am using the "objectid" field and "globalid" field from feature_layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;related_query = feature_layer.query_related_records(object_ids='objectid', relationship_id='globalid')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I get the error:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;RuntimeError&lt;/SPAN&gt;:&amp;nbsp; Unable to perform query. Please check your parameters. (Error Code: 400)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;UL&gt;&lt;LI&gt;Note:&lt;BR /&gt;The feature layer and table are indeed related 1 to many globalid to parentglobalid&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't been able to find a good example to model from. Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Nov 2018 17:51:02 GMT</pubDate>
    <dc:creator>BenjaminSperry1</dc:creator>
    <dc:date>2018-11-01T17:51:02Z</dc:date>
    <item>
      <title>Python API query_related_records() how to?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-related-records-how-to/m-p/876547#M4929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a feature layer containing points. I have a related table that has a multiple records for each point feature.&lt;/P&gt;&lt;P&gt;How can I query and use the data from the related records?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the python API documentation I wrote the following in Jupyter Notebook:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# get the feature layer collection from AGOL&lt;BR /&gt;feature_layer_collection = gis.content.get('08d12e0*****4379bd5881f26539838e')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get the feature layer of interest&lt;BR /&gt;feature_layer = feature_layer_collection.layers[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get the related table of interest&lt;BR /&gt;feature_table = feature_layer_collection.tables[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# query the related records from feature_table&lt;BR /&gt;# I am using the "objectid" field and "globalid" field from feature_layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;related_query = feature_layer.query_related_records(object_ids='objectid', relationship_id='globalid')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I get the error:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;RuntimeError&lt;/SPAN&gt;:&amp;nbsp; Unable to perform query. Please check your parameters. (Error Code: 400)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;UL&gt;&lt;LI&gt;Note:&lt;BR /&gt;The feature layer and table are indeed related 1 to many globalid to parentglobalid&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't been able to find a good example to model from. Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2018 17:51:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-related-records-how-to/m-p/876547#M4929</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2018-11-01T17:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python API query_related_records() how to?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-related-records-how-to/m-p/876548#M4930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I figured it out by reading the REST API documentation &lt;A class="link-titled" href="https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm" title="https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm"&gt;Query Related Records (Feature Service)—ArcGIS REST API: Services Directory | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just in case anyone is as baffled as I was:&lt;/P&gt;&lt;P&gt;the object ID it is asking for is that actual object ID of the source feature&lt;/P&gt;&lt;P&gt;the relationship id is an identifier you can find by looking at the service page under "&lt;STRONG&gt;Relationships:&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2018 18:18:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/python-api-query-related-records-how-to/m-p/876548#M4930</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2018-11-01T18:18:52Z</dc:date>
    </item>
  </channel>
</rss>

