Select to view content in your preferred language

Sharing Options for Python Map Image Layer Automation

Jump to solution
03-22-2020 03:54 PM
New Contributor III

Having been referred to the overwrite option for sharing a map image layer in python, I am wondering if there is an option to allow for sharing with a group or, within the organization or, with everyone.  In the documentation for the method, there does not seem to be a sharing parameter option.  I was thinking about a solution like where I search for the layer and then update the parameter was  available option if there is no method in the other sharing option.  However i cannot get this code to actually update that parameter.   Here is the code I am trying:

from arcgis.gis import GIS
portal = ""
user = "      "
password = "     "
service = "WebUpdate"
gis = GIS(portal, user, password)
print("Search for original SD on portal…")
search_results ="{} AND owner:{}".format(service, user), item_type="Map Image Layer")[0]
print("Found SD: {}, ID: {} ".format(search_results.title,
feature_layer_item = search_results[0]
print("Setting sharing options…")
print("Finished updating: {} – ID: {}".format(feature_layer_item.title,

Anything I can do to through code to change the sharing for a map image layer?

0 Kudos
1 Solution

Accepted Solutions
New Contributor III

This worked, thank you!

View solution in original post

0 Kudos
2 Replies
Esri Esteemed Contributor

Hey Clinton,

Try the below:

from arcgis.gis import GIS

# Varibales
portal = ''
username = 'gisuser'
password = '******'
mapImageLayer = 'WebUpdate'  # Service Name

# Connect to Portal
gis = GIS(portal, username, password)

# Search and share map service
search_results ='title: {0} AND owner: {1}'.format(mapImageLayer, username), item_type = 'Map Image Layer')
map_image_item = search_results[0]
New Contributor III

This worked, thank you!

0 Kudos