arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Adding or Cloning a Site in ArcGIS Enterprise results in an incorrect URL for the item

Open sverkerEsriSE opened this issue 1 year ago • 0 comments

Describe the bug When adding or cloning an ArcGIS Enterprise Site with the "clone" function in the Python API, the url of the new site will be incorrect.

To Reproduce Steps to reproduce the behavior:

from arcgis.gis import GIS
gis = GIS(portal_url, username, password)

site_manager = gis.sites
site_id = "XXXXXXXX"
old_site = site_manager.get(site_id)
cloned_site = site_manager.clone(old_site)
print(new_site.item.url)

added_site = site_manager.add("Newly added site")
print(added_site.item.url)

Expected behavior The cloned or added site has a working URL

Platform (please complete the following information):

  • Python API Version 2.2.0.1

Additional context The problem for adding is in line 907 of arcgis/apps/hub/sites.py The problem for cloning is in line 1117 of arcgis/apps/hub/sites.py

domain = "https://" + self._gis.url[8:-5] + "apps/sites/#/" + subdomain

This will effectivley strip away the web adaptor part of the URL, depending on how long the web adaptor context is. We usually use /portal, so the new site will end up with a URL of https://arcgis.domain.com/papps/sites/#/site-name

Workaround after the new site is created update its properties

new_site_item = new_site.item # or new_site_item = gis.content.get(new_site.itemid)
new_site_item.update({'url': new_site_item.url.replace("/papps/","/portal/apps/"}

sverkerEsriSE avatar Dec 11 '23 14:12 sverkerEsriSE