<?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: Overwrite Hosted Feature Layer Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/179063#M13754</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1 data-reactid="11" style="background: #ffffff; border: 0px; font-weight: 300; font-size: 28px; margin: 0px 18px 0px 0px;"&gt;Hey James,&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frist you need to change the page. what you need to put is your portal adress, where you do the login.&lt;/P&gt;&lt;P&gt;&lt;A href="https://your"&gt;https://your&lt;/A&gt;portalhere.com.br&lt;BR /&gt;Also you need to change the names of Sddraft and sd to the name of your sd in your case&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;VMRC Data. Verify spaces, because it can be a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Important: check and replace all " because it cam be generate a error in your python.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Oct 2020 11:57:51 GMT</pubDate>
    <dc:creator>BrunoGomes_de_Souza</dc:creator>
    <dc:date>2020-10-27T11:57:51Z</dc:date>
    <item>
      <title>Overwrite Hosted Feature Layer Script</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/179062#M13753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to edit a script in order to automate updating a hosted feature layer on our Enterprise page.&amp;nbsp; I acquired the script from here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/216491"&gt;Automate overwrite web layer, feature class&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.esri.com/arcgis-blog/products/api-python/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/?rmedium=redirect&amp;amp;rsource=/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python" title="https://www.esri.com/arcgis-blog/products/api-python/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python/?rmedium=redirect&amp;amp;rsource=/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-and-the-arcgis-api-for-python"&gt;Updating your hosted feature services with ArcGIS Pro and the ArcGIS API for Python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://support.esri.com/en/technical-article/000023164" title="https://support.esri.com/en/technical-article/000023164"&gt;How To: Overwrite hosted feature services from ArcGIS Pro to ArcGIS Online using Python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the script, it prints "Creating SD file" and then PRO crashes about a minute later.&amp;nbsp; I have tried running it with PRO closed from IDLE and the get the same result.&amp;nbsp; I have tried tweaking some of the information with the same result, 6 or 7 times now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the script I am running:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os, sys&lt;BR /&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;### Start setting variables&lt;BR /&gt;# Set the path to the project&lt;BR /&gt;prjPath = r"C:\Users\Documents\ArcGIS\Projects\VMRC_TEST\VMRC_TEST.aprx"&lt;/P&gt;&lt;P&gt;# Update the following variables to match:&lt;BR /&gt;# Feature service/SD name in arcgis.com, user/password of the owner account&lt;BR /&gt;sd_fs_name = "VMRC Data"&lt;BR /&gt;portal = "https://MyOrganizationsEnterpriseAddress/e4portal/sharing/rest/content/items/e74a684af7ee45a1b346cf9c6ba1d8c1" # Can also reference a local portal&lt;BR /&gt;user = ""&lt;BR /&gt;password = ""&lt;/P&gt;&lt;P&gt;# Set sharing options&lt;BR /&gt;shrOrg = True&lt;BR /&gt;shrEveryone = False&lt;BR /&gt;shrGroups = ""&lt;/P&gt;&lt;P&gt;### End setting variables&lt;/P&gt;&lt;P&gt;# Local paths to create temporary content&lt;BR /&gt;relPath = r"C:\Users\Documents\ArcGIS\Projects"&lt;BR /&gt;sddraft = os.path.join(relPath, "WebUpdate.sddraft")&lt;BR /&gt;sd = os.path.join(relPath, "WebUpdate.sd")&lt;/P&gt;&lt;P&gt;# Create a new SDDraft and stage to SD&lt;BR /&gt;print("Creating SD file")&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;prj = arcpy.mp.ArcGISProject(prjPath)&lt;BR /&gt;mp = prj.listMaps()[0]&lt;BR /&gt;arcpy.mp.CreateWebLayerSDDraft(map_or_layers=mp, out_sddraft=sddraft, service_name=sd_fs_name, server_type="HOSTING_SERVER", service_type="FEATURE_ACCESS", folder_name=None, overwrite_existing_service=True, copy_data_to_server=True, enable_editing=False, allow_exporting=False, enable_sync=True)&lt;BR /&gt;arcpy.StageService_server(sddraft, sd)&lt;/P&gt;&lt;P&gt;print("Connecting to {}".format(portal))&lt;BR /&gt;gis = GIS(portal, user, password)&lt;/P&gt;&lt;P&gt;# Find the SD, update it, publish /w overwrite and set sharing and metadata&lt;BR /&gt;print("Search for original SD on portal…")&lt;BR /&gt;sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]&lt;BR /&gt;print("Found SD: {}, ID: {} n Uploading and overwriting…".format(sdItem.title, sdItem.id))&lt;BR /&gt;sdItem.update(data=sd)&lt;BR /&gt;print("Overwriting existing feature service…")&lt;BR /&gt;fs = sdItem.publish(overwrite=True)&lt;/P&gt;&lt;P&gt;if shrOrg or shrEveryone or shrGroups:&lt;BR /&gt; print("Setting sharing options…")&lt;BR /&gt; fs.share(org=shrOrg, everyone=shrEveryone, groups=shrGroups)&lt;/P&gt;&lt;P&gt;print("Finished updating: {} – ID: {}".format(fs.title, fs.id))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing I am also not clear about it if I am using PRO while I run the script, and logged onto our enterprise portal, do I need the username and password filled in? We use an API key for ours, so there is no username and password in order to log on our Enterprise site.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the portal=&amp;nbsp;name, I have it pointing directly to my content page.&amp;nbsp; Could that be messing it up?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2020 19:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/179062#M13753</guid>
      <dc:creator>JamesWhite5</dc:creator>
      <dc:date>2020-10-23T19:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Hosted Feature Layer Script</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/179063#M13754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1 data-reactid="11" style="background: #ffffff; border: 0px; font-weight: 300; font-size: 28px; margin: 0px 18px 0px 0px;"&gt;Hey James,&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frist you need to change the page. what you need to put is your portal adress, where you do the login.&lt;/P&gt;&lt;P&gt;&lt;A href="https://your"&gt;https://your&lt;/A&gt;portalhere.com.br&lt;BR /&gt;Also you need to change the names of Sddraft and sd to the name of your sd in your case&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;VMRC Data. Verify spaces, because it can be a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Important: check and replace all " because it cam be generate a error in your python.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:57:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/179063#M13754</guid>
      <dc:creator>BrunoGomes_de_Souza</dc:creator>
      <dc:date>2020-10-27T11:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite Hosted Feature Layer Script</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/1013177#M59399</link>
      <description>&lt;P&gt;&lt;FONT size="6"&gt;Hey BrunoGomes_de_Souza,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I was wondering if you could take a look at my script and help me?&amp;nbsp; I am getting the error in red text at the bottom.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is the script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy modules&lt;BR /&gt;import arcpy&lt;BR /&gt;import os, sys&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcpy import env&lt;BR /&gt;env.workspace= r"C:\Spam\PY\PublicParcels\Project"&lt;BR /&gt;env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;### Start setting variables&lt;BR /&gt;# location of project file&lt;BR /&gt;prjPath = r"C:\Spam\PY\PublicParcels\Project\PublicParcelsUpdate.aprx"&lt;/P&gt;&lt;P&gt;# feature service name in AGOL&lt;BR /&gt;sd_fs_name="PublicParcelsTest"&lt;/P&gt;&lt;P&gt;# AGOL credentials&lt;BR /&gt;portal="&lt;A href="https://acpa.maps.arcgis.com/" target="_blank"&gt;https://acpa.maps.arcgis.com/&lt;/A&gt;"&lt;BR /&gt;user=""&lt;BR /&gt;password=""&lt;/P&gt;&lt;P&gt;# Sharing options&lt;BR /&gt;shrOrg=True&lt;BR /&gt;shrEverone=True&lt;BR /&gt;shrGroups=""&lt;/P&gt;&lt;P&gt;# local path for temp contents&lt;BR /&gt;relPath=r"C:\Spam\PY\PublicParcels\Project"&lt;BR /&gt;sddraft=os.path.join(relPath,"PublicParcelsTest.sddraft")&lt;BR /&gt;sd=os.path.join(relPath,"PublicParcelsTest.sd")&lt;/P&gt;&lt;P&gt;# create new SDDraft file and stage draft to SD file&lt;BR /&gt;print("Creating SD file")&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;prj = arcpy.mp.ArcGISProject(prjPath)&lt;BR /&gt;mp = prj.listMaps()[0]&lt;BR /&gt;arcpy.mp.CreateWebLayerSDDraft(map_or_layers=mp, out_sddraft=sddraft, service_name=sd_fs_name, server_type="HOSTING_SERVER", service_type="FEATURE_ACCESS", folder_name="ACPA Authoritative Data", overwrite_existing_service=True, copy_data_to_server=True, enable_editing=False, allow_exporting=True, enable_sync=False)&lt;BR /&gt;arcpy.StageService_server(sddraft, sd)&lt;/P&gt;&lt;P&gt;# connect to specified portal&lt;BR /&gt;print("Connecting to {}".format(portal))&lt;BR /&gt;gis=GIS(portal, user, password)&lt;/P&gt;&lt;P&gt;# locate SD file, update, and overwrite the service on the specified portal&lt;BR /&gt;print("Search for original SD on portal...")&lt;BR /&gt;sdItem=gis.content.search("{} AND owner:{}".format(sd_fs_name, user),item_type="Service Definition")[0]&lt;BR /&gt;print("Found SDE:{}, ID:{}n Uploading and overwriting....".format(sdItem.title,sdItem.id))&lt;BR /&gt;sdItem.update(data=sd)&lt;BR /&gt;print("Overwriting existing feature service...")&lt;BR /&gt;fs=sdItem.publish(overwrite=True)&lt;/P&gt;&lt;P&gt;if shrOrg or shrEveryone or shrGroups:&lt;BR /&gt;print("Setting sharing options...")&lt;BR /&gt;fs.share(org=shrOrg, everyone=shrEveryone, groups=shrGroups)&lt;/P&gt;&lt;P&gt;print("Finished updating:{}-ID:{}".fomat(fs.title,fs.id))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is the error I am getting:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Spam\PY\PublicParcels\OverwritePublicParcel_AGOL.py", line 42, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;arcpy.mp.CreateWebLayerSDDraft(map_or_layers=mp, out_sddraft=sddraft, service_name=sd_fs_name, server_type="HOSTING_SERVER", service_type="FEATURE_ACCESS", folder_name="ACPA Authoritative Data", overwrite_existing_service=True, copy_data_to_server=True, enable_editing=False, allow_exporting=True, enable_sync=False)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\mp.py", line 105, in CreateWebLayerSDDraft&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return _convertArcObjectToPythonObject(arcgisscripting._mapping.CreateWebLayerSDDraft(*_gp_fixargs([map_or_layers, out_sddraft, service_name, server_type, service_type, folder_name, overwrite_existing_service, copy_data_to_server, enable_editing, allow_exporting, enable_sync, summary, tags, description, credits, use_limitations], True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 16:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-hosted-feature-layer-script/m-p/1013177#M59399</guid>
      <dc:creator>AmandaBishop2018</dc:creator>
      <dc:date>2020-12-31T16:45:22Z</dc:date>
    </item>
  </channel>
</rss>

