2

According to the documentation for arcpy.mp.CreateSharingDraft(), the argument draft_value can be

A Map, Layer or list of layers. You can use a subset of layers from a map to publish.

Passing a map object or a single layer object works as expected. However, I get an error if I try to pass a list of layers (or a subset of layers).

service = "MapServiceDraftExample"
aprx = arcpy.mp.ArcGISProject("MyProject.aprx"))
m = aprx.listMaps("MyMap")[0]
layers = m.layerList()
# works
service_draft = arcpy.sharing.CreateSharingDraft(
  "STANDALONE_SERVER",
  "MAP_SERVICE",
  service,
  m
)
# also works
service_draft = arcpy.sharing.CreateSharingDraft(
  "STANDALONE_SERVER",
  "MAP_SERVICE",
  service,
  layers[0]
)
# does not work
service_draft = arcpy.sharing.CreateSharingDraft(
  "STANDALONE_SERVER",
  "MAP_SERVICE",
  service,
  layers
)
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py", line 100, in CreateSharingDraft
    map_service.draftValue = draft_value._arc_object #todo: temp fix
AttributeError: 'list' object has no attribute '_arc_object'

Am I misunderstanding the documentation or is there some other type of "layer list" object that is expected here?

0

1 Answer 1

1

I reported this to Esri and after some discussion with the support tech they submitted this enhancement to the Esri development team:

ENH-000141167 Synopsis: Remove the list of layers option from the draft_value of the CreateSharingDraft arcpy function documentation as it does not return a result. In the enhancement as well I asked to provide more explanation on what a valid input would be for the list of layers or for it to be removed for clarity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.