Due to a server migration, I need to update all the service URLs to the new server. The script runs, however, I do not see the update for the layers in the web map.
I took a look at this post and attempted to implement but still no update.
Could someone please assist. Posted code below
Solved! Go to Solution.
Does it help if you save the webmap with using update directly. I just answered to similar case where layer level properties are added and saved to the webmap (with different property on the layer though) in https://community.esri.com/thread/246654-setting-the-refresh-interval-for-a-hosted-feature-layer#com...
webmap.update()
Does it help if you save the webmap with using update directly. I just answered to similar case where layer level properties are added and saved to the webmap (with different property on the layer though) in https://community.esri.com/thread/246654-setting-the-refresh-interval-for-a-hosted-feature-layer#com...
webmap.update()
Thanks Antii.
I added the wm.update() which essentially saved the webmap, which updated the service URLs.
Thanks for providing the code snippet. Is there any chance you could migrate the server, yet utilize the same urls using aliases and/or the web adaptor for routing web traffic with the same url from a different server?
That should be ok. I'm no means on expert on that topic but you could start from this page.
You need to determine the URL format used by your existing apps when connecting to ArcGIS Server. This will help you understand whether your apps need to be modified after the upgrade. Using ArcGIS Web Adaptor, you can engineer your site to match the URLs you used at earlier versions, thereby saving yourself the time and effort of updating all your app code.
Hi Joseph,
If you added the layers to your web map from items in your Portal, you may want to consider updating the item itself rather than just the layer in the web map:
Note: Hosted feature service URLs cannot be updated
from arcgis.gis import GIS
# Variables
admin = 'portaladmin'
password = '*****'
portal = 'https://gis.esri.com/portal'
gisenturl = 'https://gis-stagin.esri.com/arcgis'
gisviewurl = 'https://gis.esri.com/arcgis'
targetUser = 'jskinner'
gis = GIS(portal, admin, password, verify_cert=False)
users = gis.users.search(targetUser)
for user in users:
content = user.items()
for layer in content:
if 'hosted' not in layer.url:
if gisenturl in layer.url:
updateURL = layer.url.replace(gisenturl, gisviewurl)
layer.update(item_properties={'url':updateURL})
print("Updated {0}".format(layer.title))
folders = user.folders
for folder in folders:
content = user.items(folder=folder['title'])
for layer in content:
if gisenturl in layer.url:
updateURL = layer.url.replace(gisenturl, gisviewurl)
layer.update(item_properties={'url':updateURL})
print("Updated {0}".format(layer.title))