Updating GIS content on Portal

1726
3
Jump to solution
02-13-2020 02:30 PM
CliveSwan
Occasional Contributor II

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

0 Kudos
1 Solution

Accepted Solutions
CliveSwan
Occasional Contributor II
3 Replies
by Anonymous User
Not applicable

Hi Clive,

ArcGIS Online Assistant is you friend here.

You can edit the resources JSON file directly and it even has a "find and replace" function.

It can also transfer items from one portal to another.

You can even host it yourself if you like
GitHub - Esri/ago-assistant: A swiss army knife for your ArcGIS Online and Portal for ArcGIS account... 

This is the unsung utility that can help you more than you think...

Just be careful, because you are editing the items JSON, you can also break it pretty quickly.

Have fun

Michael

CliveSwan
Occasional Contributor II
by Anonymous User
Not applicable

Fantastic, I will keep that one in mind.

Pity that the client didn't want to use AGO Assistant though.

Have fun