Hmm, thanks for pursuing this @NicolasGIS - @MarleyGeddes , do you (or anyone else @BillFox ) know if sharing items to groups through the ArcGIS Api for Python or, in the case of feature layer writes and overwrites via sddraft + sd files via the ArcPy sharing module is impacted at 11.1 - or is it just through the Content or item details pages?
For example, using the api I update sharing all the time:
try:
portItems = gis.content.search(query="owner:myusername_portal", item_type="Feature Layer", sort_field="title", sort_order="asc", max_items=5000)
for portItem in portItems:
if (portItem.title == "CPBoundary"):
portFL = FeatureLayerCollection.fromitem(portItem)
print (portItem.title)
portFL.manager.update_definition(updateDict)
#portItem.update(item_properties=itemProperties) #,data=None, thumbnail=None, metadata=None)
portItem.share(everyone=False,org=False,groups="mylonggroupid")
print(portFL.properties)
message = message + "\n" + "1. " + (portItem.title) + " Sync Enabled: " + str(portFL.properties.syncEnabled)
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
print(e.args[0])
print ("Line %i" % tb.tb_lineno)
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + str(e)
or use the sharing module for overwrites:
try:
portal = arcpy.SignInToPortal("https://host.org.net/portal", "myusername_portal", "mypassword")
aprx = arcpy.mp.ArcGISProject('C:/ArcProProjects3x/PortalUpdates/PortalUpdates.aprx')
for m in aprx.listMaps("Facility Layers"):
print("Map: " + m.name)
for lyr in m.listLayers():
if lyr.name == 'CurrentCodeViolationPoint':
lyrList = []
lyrList.append(m.listLayers(lyr.name)[0])
print(lyr.name)
stageSDDraft(m, lyr.name, "The Code Violation Point layer contains various types of property, building, zoning, resource protection and other code compliance issues for . . .",
lyrList,"The Code Violation Point layer contains various types of property, building, zoning, resource protection and other code compliance issues for. . . ",
"ServiceSafetyLayers","Planning,Services","FacilitySafety")
print(lyr.name + " Draft Created")
arcpy.StageService_server('C:/ArcProProjects3x/PortalUpdates/FacilitySafety/' + lyr.name + '.sddraft', 'C:/ArcProProjects3x/PortalUpdates/FacilitySafety/' + lyr.name + '.sd')
print(lyr.name + " Service Staged")
arcpy.UploadServiceDefinition_server('C:/ArcProProjects3x/PortalUpdates/FacilitySafety/' + lyr.name + '.sd', 'My Hosted Services', "","","","","","OVERRIDE_DEFINITION","SHARE_ONLINE","PRIVATE",
"NO_SHARE_ORGANIZATION","MyGroup") #Code Enforcement and Planning Group
print(lyr.name + " Service Uploaded")
message = message + "\n" + "2. " + (lyr.name) + " Service Uploaded"
except Exception:
# if an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
print(e.args[0])
print ("Line %i" % tb.tb_lineno)
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + str(e)#e.message
I can't test this because I'm not at 11.1 yet obviously....