Problem:
When using arcpy to publish a web layer/feature layer collection, I am not getting the item.get_data() object that lists the fields, pop-ups, etc.
Code follows.
Scenario:
* Have a set of maps in a Pro project, each having multiple layers. Pro v3.0.3
* Script loops through these, publishing each of these as web layer (feature layer collection)
* Publish script runs fine, except that I do not get the data object (i.e. 'text' in item properties I believe) created when I look at it in Assistant.
* If I publish the same map manually from Pro, I get the data object. (Share > Publish web layer)
Need this object (specifically, the layers) for the remainder of the scripting that updates popups, field settings, etc. Item object looks as expected except for missing the item.get_data() object. The JSON in the REST end point looks as expected. Feature layer collection functions as expected.
What am I missing? Is there a subsequent step needed to manifest this object in the item?
aprx_file = 'path/to/file.aprx'
folder_name = 'Existing_folder_name'
group_name = 'Some group name'
server_type = 'HOSTING_SERVER'
aprx = arcpy.mp.ArcGISProject(aprx_file)
map_objects = aprx.listMaps()
for map_object in map_objects:
sddraft = map_object.getWebLayerSharingDraft(
server_type = server_type,
service_type = 'FEATURE',
service_name = map_object.name
)
sddraft.exportToSDDraft(sddraft_filename)
arcpy.server.StageService(sddraft_filename, sd_filename)
arcpy.server.UploadServiceDefinition(
in_sd_file = sd_filename,
in_server = server_type,
in_service_name = service_name,
in_folder_type = 'EXISTING',
in_folder = folder_name,
in_override = 'OVERRIDE_DEFINITION',
in_public = "PRIVATE",
in_organization = 'NO_SHARE_ORGANIZATION',
in_groups = [group_name])

