<?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 updateDefinition - rebuilding spatial indexes - error 400 Cannot perform query Invalid query parameters in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/updatedefinition-rebuilding-spatial-indexes-error/m-p/1526630#M4824</link>
    <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Am using the &lt;STRONG&gt;updateDefinition&lt;/STRONG&gt; API to rebuild spatial indexes of layers in an AGOL Feature Service from python.&lt;/P&gt;&lt;P&gt;For some Feature Services the code below returns: &lt;FONT color="#000080"&gt;{"success":true}&lt;/FONT&gt;&lt;BR /&gt;But other Feature Services, using the same code below, return an error:&lt;BR /&gt;&lt;FONT color="#333399"&gt;{"error":{"code":400,"message":"","details":["Cannot perform query. Invalid query parameters."]}}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Does a Feature Service need specific settings to allow an &lt;STRONG&gt;updateDefinition&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json
import requests

updateDefinition_url_format = """{featureservice_url}/{layerid}/updateDefinition?token={token}&amp;amp;updateDefinition={{"indexes":[{{"name":"{spatialindexname}","fields":"Shape"}}]}}&amp;amp;f=json"""

url = updateDefinition_url_format.format(
    featureservice_url=featureservice_url,
    layerid=layerid,
    token=token,
    spatialindexname=spatialindexname)
response = requests.post(url = url)

print(response.status_code, response.text)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: &lt;FONT color="#333399"&gt;featureservice_url&lt;/FONT&gt; is the Feature Service URL found on the Overview page:&lt;BR /&gt;eg: &lt;FONT color="#333399"&gt;&lt;A href="https://services9.arcgis.com/Ukx32kQ0G9qTC0D/arcgis/rest/services/" target="_blank" rel="noopener"&gt;https://services9.arcgis.com/Ukx32kQ0G9qTC0D/arcgis/rest/services/&lt;/A&gt;&amp;lt;featureservicename&amp;gt;/FeatureServer&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Aug 2024 19:04:37 GMT</pubDate>
    <dc:creator>ar99</dc:creator>
    <dc:date>2024-08-23T19:04:37Z</dc:date>
    <item>
      <title>updateDefinition - rebuilding spatial indexes - error 400 Cannot perform query Invalid query parameters</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/updatedefinition-rebuilding-spatial-indexes-error/m-p/1526630#M4824</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Am using the &lt;STRONG&gt;updateDefinition&lt;/STRONG&gt; API to rebuild spatial indexes of layers in an AGOL Feature Service from python.&lt;/P&gt;&lt;P&gt;For some Feature Services the code below returns: &lt;FONT color="#000080"&gt;{"success":true}&lt;/FONT&gt;&lt;BR /&gt;But other Feature Services, using the same code below, return an error:&lt;BR /&gt;&lt;FONT color="#333399"&gt;{"error":{"code":400,"message":"","details":["Cannot perform query. Invalid query parameters."]}}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Does a Feature Service need specific settings to allow an &lt;STRONG&gt;updateDefinition&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json
import requests

updateDefinition_url_format = """{featureservice_url}/{layerid}/updateDefinition?token={token}&amp;amp;updateDefinition={{"indexes":[{{"name":"{spatialindexname}","fields":"Shape"}}]}}&amp;amp;f=json"""

url = updateDefinition_url_format.format(
    featureservice_url=featureservice_url,
    layerid=layerid,
    token=token,
    spatialindexname=spatialindexname)
response = requests.post(url = url)

print(response.status_code, response.text)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: &lt;FONT color="#333399"&gt;featureservice_url&lt;/FONT&gt; is the Feature Service URL found on the Overview page:&lt;BR /&gt;eg: &lt;FONT color="#333399"&gt;&lt;A href="https://services9.arcgis.com/Ukx32kQ0G9qTC0D/arcgis/rest/services/" target="_blank" rel="noopener"&gt;https://services9.arcgis.com/Ukx32kQ0G9qTC0D/arcgis/rest/services/&lt;/A&gt;&amp;lt;featureservicename&amp;gt;/FeatureServer&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 19:04:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/updatedefinition-rebuilding-spatial-indexes-error/m-p/1526630#M4824</guid>
      <dc:creator>ar99</dc:creator>
      <dc:date>2024-08-23T19:04:37Z</dc:date>
    </item>
  </channel>
</rss>

