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))
Can you explain the advantage of this route? We just migrated from one hosting server to two (added a dedicated map image server). Our system admins cloned everything so now I have two of every service in portal; one on the old hosting server and one on the new map server. These are all reference registered feature services and the database has not moved. I'm not sure why this approach was taken but now I need to repoint all the data in my web maps to the services on the new server. I was thinking that I might be able to use the API to do this? Looping through all of my content to build an old server:new server dict and then looping through my maps, and using the dict to replace the old server URLs. Most maps have a high level of customization for symbology, pop ups, etc. so I really don't want to start over from scratch. Another thought I had was editing the JSON to update URL and itemID for the operational layers, but that seems less certain and more sketchy. Any advice is appreciated.