Select to view content in your preferred language

Published web layers from script not creating data object for popups, etc.

460
2
04-13-2023 07:46 AM
CassKalinski
Occasional Contributor

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])

 

CassKalinski_0-1681397032001.png

 

CassKalinski_1-1681397119585.png

 

2 Replies
StephenRhea_NV5
Occasional Contributor

I'm experiencing the same issue with Pro 2.9, and the best reason I can find so far is that there appears to be a bug in the Python API where popups are ignored when publishing (BUG-000139253). There's a code sample on this post that'll get you most of the way there towards building the schema, then you just need to call item.update() with an object where "text" is set to the popup schema. One caveat I discovered today is that it doesn't work if fields haven't been specifically configured.

0 Kudos
ClangDevGuy
New Contributor III

Hey @CassKalinski , I am running into the exact same issue, even in ArcGIS pro 3.2.1. Its very frustrating when you are trying to standardize publishing with automation. 

Our current workaround, is if its a new service, publish from ArcGIS Pro directly (it will create data.json, that was missing from your screenshot). Then any update or changes from aprx, I run the overwrite service and change the data.json myself using the Portal Rest API.

   

0 Kudos