AnsweredAssumed Answered

Updating GIS content on Portal

Question asked by cliveswan on Feb 13, 2020
Latest reply on Feb 14, 2020 by cliveswan

Greetings,

 

The fragment below works, cloning GIS content from Portal A to B.

gis2.content.clone_items(data, copy_data=True, search_existing_items=True)

 

However, the REST URL is copied across ie it has the wrong REST in Portal B. 

I read the ESRI article: https://developers.arcgis.com/python/sample-notebooks/using-and-updating-gis-content/

 

The web map has a number of "values" eg: id, title, url, etc. So I tried to use the method in updating GIS content:

 

gis2 = GIS(target_portal, username=admin, password=passw, verify_cert=False)
print("LOGGED IN TARGET")

####MAP ID
#map id
search_result = gis2.content.get('4aa844d480704a7392a1bc0b992dee2d')
print("MAP")
display(search_result)

##search_result.layers

#MAP SEARCH
search_result_json = gis2.content.search('title:LQSP', item_type="*")
#display(search_result_json)

#CREATE MAP OBJECT
wm_item = search_result_json[0]

from arcgis.mapping import WebMap
web_map_obj = WebMap(wm_item)
## display(web_map_obj) ### prints map

#DISPLAY JSON
print("WEB MAP OBJ")
web_map_obj.layers

print("DISPLAYS JSON: ")
#display(web_map_obj.layers)

for lyr in web_map_obj.layers:
print(lyr.title + " " + lyr.url)

 

The section to update the url value is below, this fails??

web_map_obj.update(url='<server>arcgis/rest/services/<map>/MapServer')

 

I want to update the url from: 

<DEV.gov.uk>arcgis/rest/services/<map>/MapServer

TO:

<TEST.gov.uk>arcgis/rest/services/<map>/MapServer

 

I welcome any suggestions.

Regards,

Clive

Outcomes