Hey Everyone,
#Publish layer to Geohub
#Create FeatureSharing draft object and allow overwriting
server_type = "HOSTING_SERVER"
service_type = "FEATURE"
service_name = "Deed_Notice_Inspections"
FSD = MP.getWebLayerSharingDraft(server_type, service_type, service_name, Publish) #creates draft service definition
#Assign Feature Service Definition properties
FSD.overwriteExistingService = True #overwrites existing layer on portal service
FSD.allowExporting = False #allow exporting of feature layer
FSD.credits = credits #sets credits
FSD.description = description #Sets description
FSD.offine = False #must be connected to portal to create service definition
FSD.portalFolder = "Deed Notice Inspections" #portal where feature will be saved
FSD.overwriteExistingService = True #overwrites existing layer on portal service
FSD.summary = summary #sets summary
FSD.tags = tags #sets tags
#create path to Service definition draft file
sddraft = service_name + ".sddraft"
sddraftpath = os.path.join(defaultfolder, sddraft)
#Create Service definition draft file
FSD.exportToSDDraft(sddraftpath)
#read draft file
docs = DOM.parse(sddraftpath)
key_list = docs.getElementsByTagName('Key')
value_list = docs.getElementsByTagName('Value')
#Sharing level
Share_Organization = "false"
Share_Everyone = "false"
Share_Group = "true"
#Sharing to Deed Notice Inspection Tool Group
GroupID = "a49bff8206a1412991219a39ae4067ed"
#set sharing values
for i in range(key_list.length):
if key_list[i].firstChild.nodeValue == "PackageUnderMyOrg":
value_list[i].firstChild.nodeValue = Share_Organization
if key_list[i].firstChild.nodeValue == "PackageIsPublic":
value_list[i].firstChild.nodeValue = Share_Everyone
if key_list[i].firstChild.nodeValue == "PackageShareGroups":
value_list[i].firstChild.nodeValue = Share_Group
if Share_Group == "true" and key_list[i].firstChild.nodeValue == "PackageGroupIDs":
value_list[i].firstChild.nodeValue = GroupID
#write to sddraft file
f = open(sddraftpath, 'w')
docs.writexml(f)
f.close()
sd = service_name + ".sd"
sdpath = os.path.join(defaultfolder, sd)
#stage service
arcpy.SetProgressorLabel("Staging Service")
arcpy.server.StageService(sddraftpath, sdpath, 300)
#Share to portal
arcpy.SetProgressorLabel("Publishing Service")
arcpy.server.UploadService(sdpath, server_type)
In the attached code, I am trying to publish a feature layer and just the feature layer. everything works up until line 61 when I get error: ERROR 001272: Analyzer errors were encountered ([{"code":"00102","message":"Selected layer does not contain a required layer type for web feature layer","object":"Map"}]
EDIT: corrected error code message
It is my understanding that the way my script is set up is that instead of publishing the map as a web layer it will publish the feature class as a web feature layer.
However, the error is saying that I am missing the Map object, which in my project has the default name "Map".
If I instead try to publish the entire map I receive an error that says the feature layer path is inaccessible but it is saved in the default geodatabase for the project.
I will update as I continue to troubleshoot the issue with any new developments.