<?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: Publish feature class returns error: ERROR 999999 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570544#M73405</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;&amp;nbsp;No, it was published okay. I tried checking the history to see if the 'Copy to Python' command was available when sharing, but it does not exist.&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":downcast_face_with_sweat:"&gt;😓&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2024 12:31:44 GMT</pubDate>
    <dc:creator>JV_</dc:creator>
    <dc:date>2024-12-20T12:31:44Z</dc:date>
    <item>
      <title>Publish feature class returns error: ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570121#M73394</link>
      <description>&lt;P&gt;I'm trying to publish a feature class and following this procedure:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.3/arcpy/sharing/featuresharingdraft-class.htm" target="_blank" rel="nofollow noopener"&gt;https://pro.arcgis.com/en/pro-app/3.3/arcpy/sharing/featuresharingdraft-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but is giving the error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JV__0-1734608316929.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/122111iA4E06F0778854F11/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JV__0-1734608316929.png" alt="JV__0-1734608316929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have checked this post:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/publishing-feature-class-returns-error/m-p/1477664#M70647" target="_blank"&gt;https://community.esri.com/t5/python-questions/publishing-feature-class-returns-error/m-p/1477664#M70647&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But for me his solution didn't work.&lt;/P&gt;&lt;P&gt;here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set output directory path
outdir = r".\Output"

# Check if the output directory exists, if not, create it
if not os.path.exists(outdir):
    os.makedirs(outdir)
    print(f"Output directory '{outdir}' created.")
else:
    print(f"Output directory '{outdir}' already exists.")
    
service_name = "FeatureSharingDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
# Create FeatureSharingDraft and set metadata, portal folder, export data properties, and CIM symbols
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name)
sddraft.credits = "These are credits"
sddraft.description = "This is description"
sddraft.summary = "This is summary"
sddraft.tags = "tag1, tag2"
sddraft.useLimitations = "These are use limitations"
sddraft.portalFolder = "my folder name"
sddraft.allowExporting = True
sddraft.useCIMSymbols = True
# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Read the .sddraft file
docs = DOM.parse(sddraft_output_filename)
key_list = docs.getElementsByTagName('Key')
value_list = docs.getElementsByTagName('Value')

# Change following to "true" to share
SharetoOrganization = "false"
SharetoEveryone = "false"
SharetoGroup = "true"
# If SharetoGroup is set to "true", uncomment line below and provide group IDs
GroupID = "f07fab920d71339cb7b1291e3059b7a8"    # GroupID = "f07fab920d71339cb7b1291e3059b7a8, e0fb8fff410b1d7bae1992700567f54a"

# Each key has a corresponding value. In all the cases, value of key_list[i] is value_list[i].
for i in range(key_list.length):
    if key_list[i].firstChild.nodeValue == "PackageUnderMyOrg":
        value_list[i].firstChild.nodeValue = SharetoOrganization
    if key_list[i].firstChild.nodeValue == "PackageIsPublic":
        value_list[i].firstChild.nodeValue = SharetoEveryone
    if key_list[i].firstChild.nodeValue == "PackageShareGroups":
        value_list[i].firstChild.nodeValue = SharetoGroup
    if SharetoGroup == "true" and key_list[i].firstChild.nodeValue == "PackageGroupIDs":
        value_list[i].firstChild.nodeValue = GroupID

# Write to the .sddraft file
f = open(sddraft_output_filename, 'w')
docs.writexml(f)
f.close()

# 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")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Dec 2024 11:47:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570121#M73394</guid>
      <dc:creator>JV_</dc:creator>
      <dc:date>2024-12-19T11:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Publish feature class returns error: ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570541#M73404</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/819755"&gt;@JV_&lt;/a&gt;&amp;nbsp;if you Analyze the map by publishing it manually, are there any errors reported?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 12:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570541#M73404</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-12-20T12:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Publish feature class returns error: ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570544#M73405</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;&amp;nbsp;No, it was published okay. I tried checking the history to see if the 'Copy to Python' command was available when sharing, but it does not exist.&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":downcast_face_with_sweat:"&gt;😓&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 12:31:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570544#M73405</guid>
      <dc:creator>JV_</dc:creator>
      <dc:date>2024-12-20T12:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Publish feature class returns error: ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570566#M73406</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/819755"&gt;@JV_&lt;/a&gt;&amp;nbsp;I would test with another Pro Project, and also another ArcGIS Pro client machine.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 13:31:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publish-feature-class-returns-error-error-999999/m-p/1570566#M73406</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-12-20T13:31:04Z</dc:date>
    </item>
  </channel>
</rss>

