<?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 updating agol service definition in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-agol-service-definition/m-p/781646#M1224</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to debug the script described at:&lt;BR /&gt;&lt;A href="https://blogs.esri.com/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/"&gt;https://blogs.esri.com/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on line 41, if I use:&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;Then the wrong service definition is returned, because the name query is not strict enough. The only way to get the correct service definition is to use the id instead of owner or title, e.g.&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID, item_type= "Service Definition")[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but this throws the error: &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;IndexError: list index out of range&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The correct service definition can be returned without an IndexError if item_type is not included;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID)[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but then line 45 &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;fs = sdItem.publish(overwrite=True)&lt;/STRONG&gt;&lt;/SPAN&gt; throws:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis.py", line 3125, in publish&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;if fileType == 'shapefile':&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;UnboundLocalError: local variable 'fileType' referenced before assignment&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have any ideas on how to both get the correct service definition, and also specify item type? I've tried many different permutations of the different arguments.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Jan 2018 21:10:57 GMT</pubDate>
    <dc:creator>InyoCounty</dc:creator>
    <dc:date>2018-01-04T21:10:57Z</dc:date>
    <item>
      <title>updating agol service definition</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-agol-service-definition/m-p/781646#M1224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to debug the script described at:&lt;BR /&gt;&lt;A href="https://blogs.esri.com/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/"&gt;https://blogs.esri.com/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on line 41, if I use:&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;Then the wrong service definition is returned, because the name query is not strict enough. The only way to get the correct service definition is to use the id instead of owner or title, e.g.&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID, item_type= "Service Definition")[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but this throws the error: &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;IndexError: list index out of range&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The correct service definition can be returned without an IndexError if item_type is not included;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID)[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but then line 45 &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace;"&gt;fs = sdItem.publish(overwrite=True)&lt;/STRONG&gt;&lt;/SPAN&gt; throws:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis.py", line 3125, in publish&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;if fileType == 'shapefile':&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;UnboundLocalError: local variable 'fileType' referenced before assignment&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have any ideas on how to both get the correct service definition, and also specify item type? I've tried many different permutations of the different arguments.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jan 2018 21:10:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-agol-service-definition/m-p/781646#M1224</guid>
      <dc:creator>InyoCounty</dc:creator>
      <dc:date>2018-01-04T21:10:57Z</dc:date>
    </item>
  </channel>
</rss>

