AnsweredAssumed Answered

Update service URLs in Web Map

Question asked by on Jan 16, 2020
Latest reply on Jan 17, 2020 by

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


import arcgis.gis
from arcgis.mapping import WebMap
import os


if __name__ == "__main__":
    gis =arcgis.gis.GIS(orgportalURL,UN,Passowrd)
    user = gis.users.get(UN)
    print ("Successfully Logged in as " + user['username'])

    webMapID = "036292a6eb7b4bdFakeWEBMAP"
    print ("Gaining attributes for web map: " + str(webMapID))
    Webmap = gis.content.get(str(webMapID))
    wm = WebMap(Webmap)


    loop = 0
    for layer in wm.layers:
        upd = layer

        if gisenturl in layer['url']:
            wm.layers[loop]['url'= layer['url'].replace(gisenturl,gisviewurl)
            print ("Service Updated for " + layer['title'])
        loop += 1