<?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 &amp;quot;Unable to perform query operation.&amp;quot;,  &amp;quot;Invalid query&amp;quot; in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102417#M3959</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a backend component that is sending a few requests to our ArcGIS server (Note: both Ids 2 and 8 are pointing to Views in the DB). The first request below is successful and data is retrieved&lt;/P&gt;&lt;PRE&gt;URL: {baseUrl}/rest/services/{environment}/ContactView/FeatureServer/2/query?where=1%3D1&amp;amp;f=pjson&amp;amp;resultOffset=0&amp;amp;resultRecordCount=500&amp;amp;outFields=*&amp;amp;returnGeometry=false&lt;BR /&gt;Response: &lt;BR /&gt;{
 "objectIdFieldName": "ObjectId",
 "globalIdFieldName": "",
 "fields": [
  {
   "name": "Name",
   "alias": "Name",
   "type": "esriFieldTypeString",
   "length": 255
  }
 ],
 "features": [ &lt;BR /&gt;    // Data&lt;BR /&gt; ],
 "exceededTransferLimit": true
}&lt;/PRE&gt;&lt;P&gt;However, the second request fails&lt;/P&gt;&lt;PRE&gt;URL: {baseUrl}/rest/services/{environment}/ContactView/FeatureServer/8/query?where=1%3D1&amp;amp;f=pjson&amp;amp;resultOffset=0&amp;amp;resultRecordCount=500&amp;amp;outFields=*&amp;amp;returnGeometry=false&lt;BR /&gt;Response:&lt;BR /&gt;{
 "error": {
  "code": 400,
  "message": "Unable to complete operation.",
  "details": [
   "Unable to perform query operation.",
   "Invalid query"
  ]
 }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The interesting thing from the second request is that if I remove the values from &lt;FONT face="courier new,courier"&gt;resultOffset&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;resultRecordCount&lt;/FONT&gt;, e.g.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;resultOffset=&amp;amp;resultRecordCount=&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The request is successful and comes back with data.&lt;/P&gt;&lt;P&gt;Not sure what would be the issue - hope someone can shed some light on this&lt;/P&gt;&lt;P&gt;UPDATE: a bit more information about this, the DB View in question doesn't seem to have any problem, if I query the View directly in the DB, the View will return data. It is only when I use resultOffset and resultRecordCount in my REST request that makes this fails.&lt;/P&gt;&lt;P&gt;Does anyone know how ArcGIS tranlsate the REST query into a SQL statement?&amp;nbsp; Would it be something like the sql below?:&lt;/P&gt;&lt;P&gt;select * from MyView&lt;BR /&gt;ORDER BY (Select null)&lt;BR /&gt;OFFSET 0 ROWS FETCH NEXT 500 ROWS ONLY&lt;/P&gt;&lt;P&gt;If I run that sql above directly in the DB, I get data back from the View&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Luis&lt;/P&gt;</description>
    <pubDate>Tue, 28 Sep 2021 08:33:03 GMT</pubDate>
    <dc:creator>LuisDelValle</dc:creator>
    <dc:date>2021-09-28T08:33:03Z</dc:date>
    <item>
      <title>"Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102417#M3959</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a backend component that is sending a few requests to our ArcGIS server (Note: both Ids 2 and 8 are pointing to Views in the DB). The first request below is successful and data is retrieved&lt;/P&gt;&lt;PRE&gt;URL: {baseUrl}/rest/services/{environment}/ContactView/FeatureServer/2/query?where=1%3D1&amp;amp;f=pjson&amp;amp;resultOffset=0&amp;amp;resultRecordCount=500&amp;amp;outFields=*&amp;amp;returnGeometry=false&lt;BR /&gt;Response: &lt;BR /&gt;{
 "objectIdFieldName": "ObjectId",
 "globalIdFieldName": "",
 "fields": [
  {
   "name": "Name",
   "alias": "Name",
   "type": "esriFieldTypeString",
   "length": 255
  }
 ],
 "features": [ &lt;BR /&gt;    // Data&lt;BR /&gt; ],
 "exceededTransferLimit": true
}&lt;/PRE&gt;&lt;P&gt;However, the second request fails&lt;/P&gt;&lt;PRE&gt;URL: {baseUrl}/rest/services/{environment}/ContactView/FeatureServer/8/query?where=1%3D1&amp;amp;f=pjson&amp;amp;resultOffset=0&amp;amp;resultRecordCount=500&amp;amp;outFields=*&amp;amp;returnGeometry=false&lt;BR /&gt;Response:&lt;BR /&gt;{
 "error": {
  "code": 400,
  "message": "Unable to complete operation.",
  "details": [
   "Unable to perform query operation.",
   "Invalid query"
  ]
 }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The interesting thing from the second request is that if I remove the values from &lt;FONT face="courier new,courier"&gt;resultOffset&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;resultRecordCount&lt;/FONT&gt;, e.g.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;resultOffset=&amp;amp;resultRecordCount=&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The request is successful and comes back with data.&lt;/P&gt;&lt;P&gt;Not sure what would be the issue - hope someone can shed some light on this&lt;/P&gt;&lt;P&gt;UPDATE: a bit more information about this, the DB View in question doesn't seem to have any problem, if I query the View directly in the DB, the View will return data. It is only when I use resultOffset and resultRecordCount in my REST request that makes this fails.&lt;/P&gt;&lt;P&gt;Does anyone know how ArcGIS tranlsate the REST query into a SQL statement?&amp;nbsp; Would it be something like the sql below?:&lt;/P&gt;&lt;P&gt;select * from MyView&lt;BR /&gt;ORDER BY (Select null)&lt;BR /&gt;OFFSET 0 ROWS FETCH NEXT 500 ROWS ONLY&lt;/P&gt;&lt;P&gt;If I run that sql above directly in the DB, I get data back from the View&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Luis&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 08:33:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102417#M3959</guid>
      <dc:creator>LuisDelValle</dc:creator>
      <dc:date>2021-09-28T08:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102418#M3960</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/518402"&gt;@LuisDelValle&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Have you tried assigning the &lt;EM&gt;outFields&lt;/EM&gt; parameter to a known field or * in your GET request to see if the result changes?&lt;/P&gt;&lt;P&gt;Also try the setting true the&amp;nbsp;&lt;EM&gt;returnCountOnly&amp;nbsp;&lt;/EM&gt;and &lt;EM&gt;returnIDsOnly&lt;/EM&gt;&amp;nbsp;parameters to see if the service is connecting correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is your second table (id:8) a spatial or non-spatial view?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 04:30:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102418#M3960</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2021-09-28T04:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102436#M3961</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180019"&gt;@LongDinh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for your quick response. Both tables are non-spatial views.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried assigning the outFields parameter but the result doesn't change. If I set&amp;nbsp;&lt;EM&gt;returnCountOnly&amp;nbsp;&lt;/EM&gt;and&amp;nbsp;&lt;EM&gt;returnIDsOnly&amp;nbsp;&lt;/EM&gt;the request is successful demonstrating that the service is connecting correctly.&lt;/P&gt;&lt;P&gt;It seems that only if I set&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;resultOffset&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;resultRecordCount&lt;/EM&gt; the request will fail.&lt;BR /&gt;&lt;BR /&gt;Thinking that there might be something in the definition of the View? I can share that if needed&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 06:17:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102436#M3961</guid>
      <dc:creator>LuisDelValle</dc:creator>
      <dc:date>2021-09-28T06:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102843#M3962</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Does &lt;EM&gt;resultOffset&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;resultRecordCount&lt;/EM&gt;&amp;nbsp;work with &lt;EM&gt;returnIDsOnly&lt;/EM&gt;&amp;nbsp;set to True?&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Thinking that there might be something in the definition of the View? I can share that if needed&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This will help. Are you you applying a definition query on top of the view before publishing or is this the actual definition in the Database? Are you creating the view from arcpy/ArcGIS Pro/ArcMap or through a DBMS management software?&lt;/P&gt;&lt;P&gt;I suspect it might be something to do with the indexing on the table. I found this &lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEyMDMwOA==" target="_self"&gt;BUG report&lt;/A&gt; which notes that setting the&amp;nbsp;&lt;EM&gt;resultOffset&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;resultRecordCount&lt;/EM&gt; with &lt;EM&gt;returnIDsOnly&lt;/EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;returns inconsistent results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 22:50:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102843#M3962</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2021-09-28T22:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102888#M3963</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180019"&gt;@LongDinh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The view is being created with ArcGIS Pro but as far as I know a definition query hasn't been applied on top of the view - I will check into that and share my findings and if anything changes after that.&lt;/P&gt;&lt;P&gt;Thanks a lot for sharing that article - including the&amp;nbsp;&lt;EM&gt;exceededTransferLimit&amp;nbsp;&lt;/EM&gt;property in the query is something that is not being done right now in the backend component - I will also check with that and share my findings.&lt;/P&gt;&lt;P&gt;I'm including the definition of the view. It looks messy but it is basically a series of UNION ALL of five tables for something we call internally Features (I have changed the name of the tables to FeatureOne, FeatureTwo, etc) with joins to other two tables we call Organisation and OrganisationFeatureLayer (the last one an associative table)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 00:18:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102888#M3963</guid>
      <dc:creator>LuisDelValle</dc:creator>
      <dc:date>2021-09-29T00:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102907#M3964</link>
      <description>&lt;P&gt;I was not expecting such a large definition &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt; If ArcGIS Pro has validated it, I have confidence it is an acceptable table for publishing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;EM&gt;exceededTransferLimit&lt;/EM&gt; property is a query result response property.&amp;nbsp;&lt;SPAN&gt;You would generally perform the large query (e.g.&amp;nbsp;where 1=1) and if&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;exceededTransferLimit=True&lt;/EM&gt;&lt;SPAN&gt; in your result json response, your application should then:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Get the total query record count using&amp;nbsp;&lt;EM&gt;returnCountOnly&lt;/EM&gt;, then&lt;/LI&gt;&lt;LI&gt;Paginate using the&amp;nbsp;&lt;EM&gt;resultOffset&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;resultRecordCount&lt;/EM&gt;&amp;nbsp;parameters where&amp;nbsp;&lt;EM&gt;resultOffset&lt;/EM&gt; is your REST service's &lt;EM&gt;maxRecordCount&amp;nbsp;&lt;/EM&gt;property and the total query record count, respectively.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This is workflow is described in &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm" target="_self"&gt;ArcGIS REST APIs - Services reference - Query (Feature Service/Layer)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 00:53:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1102907#M3964</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2021-09-29T00:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1105029#M3974</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180019"&gt;@LongDinh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It took me a while to get back to this post but here I am. Problem solved.&lt;/P&gt;&lt;P&gt;The issue was when we were creating the view using ArcGIS Pro, there was something missing in that process that created and issue (my theory) with the definition of the REST API for that view, that ultimately created that problem when we were sending the request with&amp;nbsp;&lt;EM&gt;resultOffset&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;resultRecordCount.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;When we created the View with a script using&amp;nbsp;&lt;SPAN&gt;arcpy, that issue was solved and sending a request with&amp;nbsp;&lt;EM&gt;resultOffset&lt;/EM&gt;&amp;nbsp;and&amp;nbsp;&lt;EM&gt;resultRecordCount&amp;nbsp;&lt;/EM&gt;is now working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm marking one of your comments as the solution as you initially asked/suggested about how we were creating the view.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks a lot mate&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 00:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1105029#M3974</guid>
      <dc:creator>LuisDelValle</dc:creator>
      <dc:date>2021-10-06T00:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: "Unable to perform query operation.",  "Invalid query"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1105030#M3975</link>
      <description>&lt;P&gt;Glad to hear you reached a solution!&lt;/P&gt;&lt;P&gt;Happy to help wherever I can &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 00:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/quot-unable-to-perform-query-operation-quot-quot/m-p/1105030#M3975</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2021-10-06T00:04:07Z</dc:date>
    </item>
  </channel>
</rss>

