<?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 Issue with Updating Web Layer in ArcGIS Pro Using Python (StageService Error) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issue-with-updating-web-layer-in-arcgis-pro-using/m-p/1598587#M73945</link>
    <description>&lt;P&gt;I am trying to save a web layer by overwriting the existing feature service using the&amp;nbsp;FeatureSharingDraft class. I am using ArcGIS Pro 3.4 with Python 3.9. I felt like I followed the documentation pretty closely.&lt;/P&gt;&lt;P&gt;Here’s my script:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

portal_url = "" 
username = ""
password = ""

arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
arcpy.SignInToPortal(portal_url,username,password)
active_portal = arcpy.GetActivePortalURL()
print(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Successfully signed into: {active_portal}")

gdb_path = r"c:\path.gdb"
feature_layer_name = "test"
sddraft_filename = feature_layer_name + ".sddraft"
sd_filename = feature_layer_name + ".sd"
sddraft_output_filename = os.path.join(gdb_path, sddraft_filename)
sd_output_filename = os.path.join(gdb_path, sd_filename)
print(sd_output_filename)

map_obj = aprx.listMaps()[0]
server_type = "HOSTING_SERVER"
sddraft = map_obj.getWebLayerSharingDraft(server_type, "FEATURE", feature_layer_name)
sddraft.overwriteExistingService = True

print(sddraft)

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)

print("Finish Publishing")
print(sddraft)&lt;/LI-CODE&gt;&lt;P&gt;Here is the output:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Successfully signed into: https://portal.maps.arcgis.com/
c:\path.gdb\test.sd
&amp;lt;arcpy.sharing.FeatureSharingDraft object at 0x0000020B90D0D950&amp;gt;
Start Staging

Line 6:     arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in &amp;lt;lambda&amp;gt;:
Line 512:   return lambda *args: val(*gp_fixargs(args, True))

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
ERROR 000814: Invalid file type
Failed to execute (StageService).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've never used this class before. Why am I using the map object instead of using a layer if I only want to update a single layer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Mar 2025 16:45:03 GMT</pubDate>
    <dc:creator>ZacharyKasson</dc:creator>
    <dc:date>2025-03-24T16:45:03Z</dc:date>
    <item>
      <title>Issue with Updating Web Layer in ArcGIS Pro Using Python (StageService Error)</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-updating-web-layer-in-arcgis-pro-using/m-p/1598587#M73945</link>
      <description>&lt;P&gt;I am trying to save a web layer by overwriting the existing feature service using the&amp;nbsp;FeatureSharingDraft class. I am using ArcGIS Pro 3.4 with Python 3.9. I felt like I followed the documentation pretty closely.&lt;/P&gt;&lt;P&gt;Here’s my script:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

portal_url = "" 
username = ""
password = ""

arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
arcpy.SignInToPortal(portal_url,username,password)
active_portal = arcpy.GetActivePortalURL()
print(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Successfully signed into: {active_portal}")

gdb_path = r"c:\path.gdb"
feature_layer_name = "test"
sddraft_filename = feature_layer_name + ".sddraft"
sd_filename = feature_layer_name + ".sd"
sddraft_output_filename = os.path.join(gdb_path, sddraft_filename)
sd_output_filename = os.path.join(gdb_path, sd_filename)
print(sd_output_filename)

map_obj = aprx.listMaps()[0]
server_type = "HOSTING_SERVER"
sddraft = map_obj.getWebLayerSharingDraft(server_type, "FEATURE", feature_layer_name)
sddraft.overwriteExistingService = True

print(sddraft)

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)

print("Finish Publishing")
print(sddraft)&lt;/LI-CODE&gt;&lt;P&gt;Here is the output:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Successfully signed into: https://portal.maps.arcgis.com/
c:\path.gdb\test.sd
&amp;lt;arcpy.sharing.FeatureSharingDraft object at 0x0000020B90D0D950&amp;gt;
Start Staging

Line 6:     arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in &amp;lt;lambda&amp;gt;:
Line 512:   return lambda *args: val(*gp_fixargs(args, True))

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
ERROR 000814: Invalid file type
Failed to execute (StageService).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've never used this class before. Why am I using the map object instead of using a layer if I only want to update a single layer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 16:45:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-updating-web-layer-in-arcgis-pro-using/m-p/1598587#M73945</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2025-03-24T16:45:03Z</dc:date>
    </item>
  </channel>
</rss>

