<?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: Automate AGOL publishing in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144926#M44425</link>
    <description>&lt;P&gt;Josh,&lt;/P&gt;&lt;P&gt;Thanks for the reply!&lt;/P&gt;&lt;P&gt;In our case, we need to drop all records and append new ones. I guess we could update the layers instead of re-publishing...&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The only issue with our script is that it seems to be dependent on the MXD being open and the line that errors out (when it is not working) is the last one arcpy.UploadServiceDefinition_server()&lt;/P&gt;&lt;P&gt;error 000732: Dataset My Hosted Services does not exist or is not supported.&lt;/P&gt;&lt;P&gt;WARNING 001404: You are not signed in to ArcGIS Online.&lt;/P&gt;&lt;P&gt;Failed to execute (UploadServiceDefinition).&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 21:48:25 GMT</pubDate>
    <dc:creator>Roli</dc:creator>
    <dc:date>2022-02-16T21:48:25Z</dc:date>
    <item>
      <title>Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144424#M44401</link>
      <description>&lt;P&gt;We are using ArcGIS Desktop 10.7.1 and trying&amp;nbsp; to automate AGOL publishing ( overwriting a service)..&lt;/P&gt;&lt;P&gt;We have a service ( created by publishing an mxd) that needs to be updated on a daily basis. We have automated the local data creation/update process using models.&lt;/P&gt;&lt;P&gt;Once the data is updated, we need to&amp;nbsp; push the updates to AGOL . One option is to re-publish the MXD and overwrite the service. However ,&amp;nbsp; there must be a better/easier way to do this!&lt;/P&gt;&lt;P&gt;Found a python script online and it seems to be working but not in a consistent way: sometimes we need to have the mxd&amp;nbsp; open and be logged in to AGOL... sometimes not...&amp;nbsp; This doesn't make sense because the script contains the credentials.&lt;/P&gt;&lt;P&gt;Not sure if this is an AGOL limitation/issue or an issue with the&amp;nbsp; python script ( see attached).&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 00:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144424#M44401</guid>
      <dc:creator>Roli</dc:creator>
      <dc:date>2022-02-16T00:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144569#M44407</link>
      <description>&lt;P&gt;I would advise against overwriting the service. As long as there's no schema change, it's not necessary, and is more likely to result in some error. We have several processes that update hosted layers on a daily basis, and we're able to use the ArcGIS Python API to do so.&lt;/P&gt;&lt;P&gt;A simplified version of it would look like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
import pandas as pd

# Log in
gis = GIS('your-portal-url', 'username', 'password')

# Get hosted layer; replace "0" with appropriate index as needed; use ".tables[0]" to get standalone tables from a service
lyr = gis.content.get('itemid of service').layers[0]

# Query source data
df = pd.read_sql('some sql query')

# Truncate existing records
lyr.manager.truncate()

# Apply new features to layer
lyr.edit_features(adds=df)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a &lt;EM&gt;lot &lt;/EM&gt;more to it than that, but the specifics will depend a lot upon where the data's coming from.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 12:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144569#M44407</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-16T12:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144721#M44418</link>
      <description>&lt;P&gt;Josh:&lt;/P&gt;&lt;P&gt;Are you using the&amp;nbsp;&lt;SPAN&gt;ArcGIS Python API to perform a truncate and append process on the hosted feature layer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Did you find this source code in an ESRI sample?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144721#M44418</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2022-02-16T16:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144739#M44419</link>
      <description>&lt;P&gt;Yes, I am, and no I didn't. The actual code is quite a bit more involved, and I wrote it up on my own.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 17:33:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144739#M44419</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-16T17:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144926#M44425</link>
      <description>&lt;P&gt;Josh,&lt;/P&gt;&lt;P&gt;Thanks for the reply!&lt;/P&gt;&lt;P&gt;In our case, we need to drop all records and append new ones. I guess we could update the layers instead of re-publishing...&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The only issue with our script is that it seems to be dependent on the MXD being open and the line that errors out (when it is not working) is the last one arcpy.UploadServiceDefinition_server()&lt;/P&gt;&lt;P&gt;error 000732: Dataset My Hosted Services does not exist or is not supported.&lt;/P&gt;&lt;P&gt;WARNING 001404: You are not signed in to ArcGIS Online.&lt;/P&gt;&lt;P&gt;Failed to execute (UploadServiceDefinition).&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 21:48:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144926#M44425</guid>
      <dc:creator>Roli</dc:creator>
      <dc:date>2022-02-16T21:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144930#M44426</link>
      <description>&lt;P&gt;Well, that's one of the benefits of the ArcGIS API. You don't need to rely on having desktop software open, making it possible to run your script on any machine with Python on it, so long as it has access to the source data.&lt;/P&gt;&lt;P&gt;Where's the data coming from? An SDE, or file-based resource?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 21:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1144930#M44426</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-16T21:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145202#M44438</link>
      <description>&lt;P&gt;Normally, the data we publish comes from SDE. However, we are trying to automate the AGOL update and let another department handle it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our first AGOL publishing was done by uploading a shp/gdb (zip).&amp;nbsp; However, because all our data is in SDE, it made not sense to continue that way and now we have MXD-s we use for publishing.&lt;/P&gt;&lt;P&gt;After some reading on this Python automation , I realized we are approaching&amp;nbsp; this the wrong way: updating/overwriting the feat. layer by uploading a zip is a better option. The fact that the data used for this automation is not coming from SDE ( it is created by a model and exported to SHP/GDB)&amp;nbsp; goes along with the zip-based update method ...&lt;/P&gt;&lt;P&gt;While we'll have to read the documentation, having a sample script would help.... Found the ESRI samples, but as always , they use the most simplistic example ( csv) and it is not as helpful as they thought it would be. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 16:13:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145202#M44438</guid>
      <dc:creator>Roli</dc:creator>
      <dc:date>2022-02-17T16:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145276#M44440</link>
      <description>&lt;P&gt;Just tested the concept above ( zip-based publishing &amp;amp; overwrite) and it is working, with one issue: the Py script requires ARCGIS module which is only available on computers with ArcGIS Pro installed.&lt;/P&gt;&lt;P&gt;When attempting to run script on PC with Desktop 10.7 ( Python 2.7 ) I get error: "Import error: No module named arcgis.gis"&lt;/P&gt;&lt;P&gt;I'd hope that installing Python 3.7 ( current version bundled with ArcGIS Pro)&amp;nbsp; we should be able to add the ARCGIS module. Do you have a computer with Python 3.5 ( or 3.7)&amp;nbsp; without ArcGIS Pro and are able to execute python scripts updating AGOL?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 18:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145276#M44440</guid>
      <dc:creator>Roli</dc:creator>
      <dc:date>2022-02-17T18:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Automate AGOL publishing</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145286#M44442</link>
      <description>&lt;P&gt;I've run our scripts on Linux CLI environments where the ArcGIS Python API is the &lt;EM&gt;only &lt;/EM&gt;Esri thing on it. You just need to have the arcgis module installed in your Python env.&lt;/P&gt;&lt;P&gt;I highly suggest using a package manager like Anaconda Navigator (or miniconda, if you're comfortable working in the command line). Then you can have a Python env specific to your automated scripts, with all the necessary modules installed. You'll need to add the &lt;STRONG&gt;esri &lt;/STRONG&gt;channel to conda so that it can actually &lt;EM&gt;see &lt;/EM&gt;the arcgis module.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 18:41:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/automate-agol-publishing/m-p/1145286#M44442</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-17T18:41:54Z</dc:date>
    </item>
  </channel>
</rss>

