AnsweredAssumed Answered

Feature Layer Query KeyError: 'count'

Question asked by elester_jctngis on Jul 2, 2018
Latest reply on Jul 2, 2018 by elester_jctngis

I am trying to query a feature layer as described here: arcgis.features module — arcgis 1.4.2 documentation but I get  KeyError: 'count' (see full error below). I'm using all the default parameters for the query, which includes return_count_only = False. I've tried this on multiple layers, including ones hosted in AGOL and ones available through our REST endpoint. Any ideas?

 

My code:

import arcgis.features as features
test = features.FeatureLayer("https://gis.johnsoncitytn.org/arcgis/rest/services/ReferenceData/Park_And_Recreation_Locations/MapServer")
print(test.query())

 

The error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-5-b9976302e36a> in <module>()
      1 import arcgis.features as features
      2 test = features.FeatureLayer("https://gis.johnsoncitytn.org/arcgis/rest/services/ReferenceData/Park_And_Recreation_Locations/MapServer")
----> 3 print(test.query())

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py in query(self, where, out_fields, time_filter, geometry_filter, return_geometry, return_count_only, return_ids_only, return_distinct_values, return_extent_only, group_by_fields_for_statistics, statistic_filter, result_offset, result_record_count, object_ids, distance, units, max_allowable_offset, out_sr, geometry_precision, gdb_version, order_by_fields, out_statistics, return_z, return_m, multipatch_option, quanitization_parameters, return_centroid, return_all_records, **kwargs)
    391
    392         params['returnCountOnly'] = True
--> 393         record_count = self._query(url, params)
    394         if 'maxRecordCount' in self.properties:
    395             max_records = self.properties['maxRecordCount']

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py in _query(self, url, params)
    824
    825         if  params['returnCountOnly']:
--> 826             return result['count']
    827         elif params['returnIdsOnly']:
    828             return result

KeyError: 'count'

Outcomes