arcpy - sharing and allowExporting settings not working

299
2
Jump to solution
06-08-2021 12:33 PM
dcafdg
by
Occasional Contributor II

I am publishing a local feature class in arcpy (in ArcGIS Pro) to a Portal hosted feature layer. Some of the settings are not coming through per the documentation. I am following the first code sample in the help almost verbatim (create sharing draft, export to service definition draft, stage service, upload service definition). 

On the sharing draft, I set it to allow exporting like this: 

 sharing_draft.allowExporting = True

I create the feature service via this command: 

arcpy.server.UploadServiceDefinition(
in_sd_file = str(sd_file),
in_server = arcpy.GetActivePortalURL(),
in_organization='SHARE_ORGANIZATION',
in_groups = ['<Group1 name>', '<Group2 name>']
)

 

When I look at the item's page, it is only shared at the owner level (should be shared to the organization) and not shared with any groups: 

dcafdg_0-1623180401000.png

After it finishes, the settings page shows allow export disabled. I would also love to know how to enable sync, if possible. 

dcafdg_1-1623180446028.png

I think some/all of this can be done in the arcgis API, but I'm already using arcpy, so I'd like to keep going with that. 

 

Note: Same outcome whether creating a new hosted feature layer or overwriting an existing one. 

 

thanks!

0 Kudos
1 Solution

Accepted Solutions
MarcoPizzolato
New Contributor

Hello,

maybe a bit late for this. 

Regarding the download option not active, I had a similar issue and I used the following code to enable it.

 

 

search_results = gis.content.search('title: '+service+"'", 'Feature Layer')

item = search_results[0]

print(item)

flc = FeatureLayerCollection.fromitem(item)

update_dict = {'capabilities':'Query,Extract,Sync'}

flc.manager.update_definition(update_dict)

 

Cheers

Marco

View solution in original post

2 Replies
MarcoPizzolato
New Contributor

Hello,

maybe a bit late for this. 

Regarding the download option not active, I had a similar issue and I used the following code to enable it.

 

 

search_results = gis.content.search('title: '+service+"'", 'Feature Layer')

item = search_results[0]

print(item)

flc = FeatureLayerCollection.fromitem(item)

update_dict = {'capabilities':'Query,Extract,Sync'}

flc.manager.update_definition(update_dict)

 

Cheers

Marco

dcafdg
by
Occasional Contributor II

Marco - thanks for posting this. This is pretty much the solution I came up with - I should have posted this.

It's super annoying that arcpy has this setting, but it doesn't work, so you have to use a different API to complete the task. It's even more annoying that when publishing with arcpy, you don't get back the item ID (at least I haven't figured that out yet), so you have to go search for the item you just created. 

0 Kudos