<?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 Re: Updating multiple feature services on AGOL using Python in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/updating-multiple-feature-services-on-agol-using/m-p/413901#M23644</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you to &amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/141183"&gt;Jing Yan&lt;/A&gt; from Esri Canada for figuring this one out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the solution:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.0pt;"&gt;In&amp;nbsp;&amp;nbsp;ArcGIS Online, the title of an item is stored in an “title” parameter (e.g. “Nicer Name”), while the original service name/SD file name is stored in a “name” parameter (e.g. “SqueezedName.sd”).&amp;nbsp;&lt;BR /&gt; &lt;BR /&gt; The high-level steps are:&amp;nbsp;&lt;BR /&gt; 1)&amp;nbsp;&amp;nbsp; &amp;nbsp;Use service name, e.g. “Nicer Name”, to fetch the same titled item, and then get item ID to decide which item and its SD to update.&amp;nbsp;&lt;BR /&gt; 2)&amp;nbsp;&amp;nbsp; &amp;nbsp;Fetch the original service name/SD file name, e.g. “SqueezedName”, through the item name parameter, and use “SqueezedName” to create new SD and overwrite the original service.&amp;nbsp;&lt;BR /&gt; 3)&amp;nbsp;&amp;nbsp; &amp;nbsp;Now the item title “Nicer Name” will be reverted back to its original service name “SqueezedName”. So the last step is to use Update Item operation to update item title with “Nicer Name”, i.e. the service name defined in settings.ini, or from the spreadsheet in your case.&lt;BR /&gt; &lt;BR /&gt; For step 1 and 2, a few things need to modify in the script:&lt;BR /&gt; 1)&amp;nbsp;&amp;nbsp; &amp;nbsp;You need to have class AGOLHandler() return both item ID and item name.&amp;nbsp;&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;The original script only returns item ID through findItem function, you would have the function to return item name as well (see 1ReturnName.png)&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;Under def __init__, you need to modify self.itemID, self.SDitemID, and add self.itemName (see 2Self. png)&lt;BR /&gt; 2)&amp;nbsp;&amp;nbsp; &amp;nbsp;Use the returned item name to create SD for overwriting the sevice &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;Under __name__ == “__main__”:, after initialize AGOLHandler class, we will create a variable e.g. originalname, to hold item name (see 3OriginalName. png)&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;This originalname will be used to create SD (see 4CreateSD.png)&lt;BR /&gt; &amp;nbsp;&lt;BR /&gt; For step 3, you would add a block of codes to re-update the item title, using Update Item API and item name parameter, which should be straightforward.&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Update_Item/02r30000009s000000/"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Update_Item/02r30000009s000000/&lt;/A&gt;&lt;BR /&gt; &lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009v000000"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009v000000&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt; Thank you Jing, &lt;/SPAN&gt;you saved me a ton of time and frustration and I believe this solution will help a lot of people with keeping their open data sites up to date.&lt;/P&gt;&lt;P&gt;Thank you so much, Melanie&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.0pt;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Sep 2016 19:06:30 GMT</pubDate>
    <dc:creator>MelanieWawryk</dc:creator>
    <dc:date>2016-09-01T19:06:30Z</dc:date>
    <item>
      <title>Updating multiple feature services on AGOL using Python</title>
      <link>https://community.esri.com/t5/data-management-questions/updating-multiple-feature-services-on-agol-using/m-p/413900#M23643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a python script that was adapted from &lt;A href="https://github.com/arcpy/update-hosted-feature-service/blob/master/update.py" title="https://github.com/arcpy/update-hosted-feature-service/blob/master/update.py"&gt;update-hosted-feature-service/update.py at master · arcpy/update-hosted-feature-service · GitHub&lt;/A&gt;&amp;nbsp; that uses an oracle table instead of the ini file to loop through AGOL updates. The table has the AGOL name, the mxd name, tags etc.that is updates but. It works fine when there are no spaces on the AGOL side but fails in the def publish(self) section on line 230&amp;nbsp; when there are spaces in AGOL.&amp;nbsp;&amp;nbsp; So for example if I have Bike Racks as BikeRacks on AGOL, it will run. I am pretty sure it is a simple error but I can seem to see it.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14701701100032523 jive_text_macro" data-renderedposition="160_50_798_16" jivemacro_uid="_14701701100032523"&gt;&lt;P&gt;Line 230: return jsonResponse['services'][0]['serviceItemId']&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;KeyError: 'services'&lt;/P&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;OK&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;Oracle table:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/214291_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;AGOL:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/214298_pastedImage_2.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14701670969754349 jive_text_macro" data-renderedposition="790_50_798_16" jivemacro_uid="_14701670969754349" modifiedtitle="true"&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2016 20:37:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/updating-multiple-feature-services-on-agol-using/m-p/413900#M23643</guid>
      <dc:creator>MelanieWawryk</dc:creator>
      <dc:date>2016-08-02T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Updating multiple feature services on AGOL using Python</title>
      <link>https://community.esri.com/t5/data-management-questions/updating-multiple-feature-services-on-agol-using/m-p/413901#M23644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you to &amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/141183"&gt;Jing Yan&lt;/A&gt; from Esri Canada for figuring this one out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the solution:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.0pt;"&gt;In&amp;nbsp;&amp;nbsp;ArcGIS Online, the title of an item is stored in an “title” parameter (e.g. “Nicer Name”), while the original service name/SD file name is stored in a “name” parameter (e.g. “SqueezedName.sd”).&amp;nbsp;&lt;BR /&gt; &lt;BR /&gt; The high-level steps are:&amp;nbsp;&lt;BR /&gt; 1)&amp;nbsp;&amp;nbsp; &amp;nbsp;Use service name, e.g. “Nicer Name”, to fetch the same titled item, and then get item ID to decide which item and its SD to update.&amp;nbsp;&lt;BR /&gt; 2)&amp;nbsp;&amp;nbsp; &amp;nbsp;Fetch the original service name/SD file name, e.g. “SqueezedName”, through the item name parameter, and use “SqueezedName” to create new SD and overwrite the original service.&amp;nbsp;&lt;BR /&gt; 3)&amp;nbsp;&amp;nbsp; &amp;nbsp;Now the item title “Nicer Name” will be reverted back to its original service name “SqueezedName”. So the last step is to use Update Item operation to update item title with “Nicer Name”, i.e. the service name defined in settings.ini, or from the spreadsheet in your case.&lt;BR /&gt; &lt;BR /&gt; For step 1 and 2, a few things need to modify in the script:&lt;BR /&gt; 1)&amp;nbsp;&amp;nbsp; &amp;nbsp;You need to have class AGOLHandler() return both item ID and item name.&amp;nbsp;&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;The original script only returns item ID through findItem function, you would have the function to return item name as well (see 1ReturnName.png)&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;Under def __init__, you need to modify self.itemID, self.SDitemID, and add self.itemName (see 2Self. png)&lt;BR /&gt; 2)&amp;nbsp;&amp;nbsp; &amp;nbsp;Use the returned item name to create SD for overwriting the sevice &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;Under __name__ == “__main__”:, after initialize AGOLHandler class, we will create a variable e.g. originalname, to hold item name (see 3OriginalName. png)&lt;BR /&gt; •&amp;nbsp;&amp;nbsp; &amp;nbsp;This originalname will be used to create SD (see 4CreateSD.png)&lt;BR /&gt; &amp;nbsp;&lt;BR /&gt; For step 3, you would add a block of codes to re-update the item title, using Update Item API and item name parameter, which should be straightforward.&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Update_Item/02r30000009s000000/"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Update_Item/02r30000009s000000/&lt;/A&gt;&lt;BR /&gt; &lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009v000000"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009v000000&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt; Thank you Jing, &lt;/SPAN&gt;you saved me a ton of time and frustration and I believe this solution will help a lot of people with keeping their open data sites up to date.&lt;/P&gt;&lt;P&gt;Thank you so much, Melanie&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.0pt;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2016 19:06:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/updating-multiple-feature-services-on-agol-using/m-p/413901#M23644</guid>
      <dc:creator>MelanieWawryk</dc:creator>
      <dc:date>2016-09-01T19:06:30Z</dc:date>
    </item>
  </channel>
</rss>

