<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Update Portal Sharing Settings in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1528752#M71328</link>
    <description>&lt;LI-CODE lang="python"&gt;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}")&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/documentation/portal-and-data-services/portal-service/sharing/sharing-items/" target="_blank"&gt;https://developers.arcgis.com/documentation/portal-and-data-services/portal-service/sharing/sharing-items/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2024 16:26:37 GMT</pubDate>
    <dc:creator>MappingDepartment</dc:creator>
    <dc:date>2024-08-28T16:26:37Z</dc:date>
    <item>
      <title>How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1023527#M59793</link>
      <description>&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 17:19:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1023527#M59793</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-02-04T17:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1023759#M59806</link>
      <description>&lt;P&gt;Might give this method a try &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.share" target="_self"&gt;arcgis.gis.Item.share&lt;/A&gt; when you upload it.&lt;/P&gt;&lt;P&gt;Should be something like youritem.share(everyone=True)&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 02:11:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1023759#M59806</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-05T02:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1024062#M59819</link>
      <description>&lt;P&gt;Thanks. Would my item be the service ID? I tried service name, but it won't accept a string.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 21:32:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1024062#M59819</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-02-05T21:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1024068#M59820</link>
      <description>&lt;P&gt;... might have gotten tripped up on 'item' and what what it is according to the Docs description.&amp;nbsp; If you are uploading layers, maybe the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update" target="_self"&gt;update&lt;/A&gt; method's&amp;nbsp;&lt;EM&gt;item_properties&lt;/EM&gt; parameter is where to set it.&lt;/P&gt;&lt;P&gt;yourItem.update(item_properties={"access" : "public"})&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 22:04:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1024068#M59820</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-05T22:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1032024#M60184</link>
      <description>&lt;P&gt;Revisiting this issue. I'm following the docs, but it's not working. I run these lines at the end of my script, but the service still says &lt;STRONG&gt;"T&lt;/STRONG&gt;&lt;STRONG&gt;he Item is not shared"&lt;/STRONG&gt;&amp;nbsp;in the portal.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;portal = GIS("https://&amp;lt;ourserver&amp;gt;/arcgis", "user", "password")
locator = portal.content.get('&amp;lt;itemID&amp;gt;')
locator.update(item_properties={"access" : "public"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 18:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1032024#M60184</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-03-02T18:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1033609#M60243</link>
      <description>&lt;P&gt;&amp;nbsp;Is anyone able to update these settings with Python?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 21:21:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1033609#M60243</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-03-05T21:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1038377#M60477</link>
      <description>&lt;P&gt;I will open a support ticket on this&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 23:12:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1038377#M60477</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-03-18T23:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070062#M61405</link>
      <description>&lt;P&gt;I have the same issue. It always sets sharing to 'private'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215649"&gt;@LeviCecil&lt;/a&gt;&amp;nbsp;has there been any update on your ticket?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 22:15:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070062#M61405</guid>
      <dc:creator>ChrisSchreiber</dc:creator>
      <dc:date>2021-06-18T22:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070064#M61407</link>
      <description>&lt;P&gt;I did not end up opening a ticket, as I stopped regular updates of the locator.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 22:21:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070064#M61407</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2021-06-18T22:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070079#M61408</link>
      <description>&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215649"&gt;@LeviCecil&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a work around using the &lt;A href="https://developers.arcgis.com/rest/users-groups-and-items/share-items.htm" target="_self"&gt;"shareItems"&lt;/A&gt; call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#get the token from the 'gis' object
token = gis._con.token
#build the URL
url = '{0}/sharing/rest/content/users/&amp;lt;userWhoOwnsItem&amp;gt;/shareItems?f=json&amp;amp;token={1}'.format(gis.url, token)
#using the Python 'Requests" module, send the request to the REST API directly.
updateSharing = requests.post(url, data={"items": "&amp;lt;id(s) go here&amp;gt;", "org": "true"})&lt;/LI-CODE&gt;&lt;P&gt;I hope this helps someone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 23:10:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1070079#M61408</guid>
      <dc:creator>ChrisSchreiber</dc:creator>
      <dc:date>2021-06-18T23:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1084329#M61897</link>
      <description>&lt;P&gt;This is just what I was after. Thanks Chris!!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 03:54:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1084329#M61897</guid>
      <dc:creator>StuartHarvey</dc:creator>
      <dc:date>2021-07-30T03:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1200508#M65247</link>
      <description>&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 18:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1200508#M65247</guid>
      <dc:creator>LeviCecil</dc:creator>
      <dc:date>2022-08-08T18:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1268754#M67133</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you explain your code a little bit? I am getting tripped up by the gis._con.token and the {0} in the url&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Kayden&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 20:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1268754#M67133</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2023-03-16T20:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Portal Sharing Settings in Python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1528752#M71328</link>
      <description>&lt;LI-CODE lang="python"&gt;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}")&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/documentation/portal-and-data-services/portal-service/sharing/sharing-items/" target="_blank"&gt;https://developers.arcgis.com/documentation/portal-and-data-services/portal-service/sharing/sharing-items/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:26:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-portal-sharing-settings-in-python/m-p/1528752#M71328</guid>
      <dc:creator>MappingDepartment</dc:creator>
      <dc:date>2024-08-28T16:26:37Z</dc:date>
    </item>
  </channel>
</rss>

