I have a script that updates geocoders every month and publishes them to our enterprise portal. When this happens I have to manually change the sharing settings to "everyone" for it to be accessible in our public school finder. If I forget to to do this, I get emails saying that the app is asking users to log into the portal. Is there a way to set the sharing settings for a service in Python?
This is just what I was after. Thanks Chris!!
Hi Chris,
Can you explain your code a little bit? I am getting tripped up by the gis._con.token and the {0} in the url
Thanks!
Kayden
So I'm back to updating my geolocators regularly. None of the solutions in the thread have worked for me to automate changing the item sharing settings to public. Has this been addressed with the new geocoder tools in Pro 3?
from arcgis.gis import GIS
# Replace 'username' and 'password' with your ArcGIS Online credentials
gis = GIS("home", "username", "password")
# Replace 'item_id' with the ID of the item you want to update
item_id = 'item_id'
# Replace 'sharing_level' with the desired sharing level ('private', 'organization', 'public')
sharing_level = 'public'
# Get the item
item = gis.content.get(item_id)
# Update the sharing level
item.share(everyone=True, org=True if sharing_level == 'organization' else False, groups='')
print(f"Sharing level of item {item_id} set to {sharing_level}")