Select to view content in your preferred language

Publish feature class returns error: ERROR 999999

425
3
12-19-2024 03:47 AM
JV_
by
Regular Contributor

I'm trying to publish a feature class and following this procedure: https://pro.arcgis.com/en/pro-app/3.3/arcpy/sharing/featuresharingdraft-class.htm

but is giving the error:

JV__0-1734608316929.png

I have checked this post: https://community.esri.com/t5/python-questions/publishing-feature-class-returns-error/m-p/1477664#M7...

 

But for me his solution didn't work.

here is my code:

# 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")
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

@JV_ if you Analyze the map by publishing it manually, are there any errors reported?

0 Kudos
JV_
by
Regular Contributor

@JakeSkinner 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. 😓

 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

@JV_ I would test with another Pro Project, and also another ArcGIS Pro client machine.

0 Kudos