Select to view content in your preferred language

arcpy Publish Feature Service from ArcPro Ignores 'capabilitites'

160
1
11-18-2024 10:14 AM
Labels (1)
RandyMcGregor_BMcD
Frequent Contributor

I am running the demo script on this page to published a hosted feature layer. 

https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm#:~:text=Service...

It works perfectly well, except that it completely ignores 'featureCapabilities' 

Here is how I want to set it up:

sddraft.featureCapabilities = "Create,Delete,Query,Update,Editing,Extract,Sync,ChangeTracking"

I've tried several options, all completely ignored in the published service.

Is there an extra step or something that I'm missing here?

Thank you for any assistance you may be able to provide.

Randy McGregor

0 Kudos
1 Reply
RandyMcGregor_BMcD
Frequent Contributor

This is the code:

import arcpy
import os

# Sign in to portal
arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword")

# Set output file names
outdir = r"C:\Project\Output"
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(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[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.featureCapabilities = "Extract"
sddraft.useCIMSymbols = True
sddraft.sharing.sharingLevel = "EVERYONE"
sddraft.sharing.groups = ""  # Group names = "group1,group2"

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# 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