Help Cloning Items Using Jupyter Notebook

2631
11
06-09-2021 07:52 AM
DaveK
by
Occasional Contributor

Hello! 

I'm trying to clone items from our AGO to our organizations enterprise Portal and vice versa. When connecting to my AGO account through the notebook it seems to work just fine. It alerts me that I am logged in as an administrator. When connecting to my Portal account it throws a number of errors including a connection error. Do I need to be an administrator to complete the cloning? Is there any issue with our portal being behind a firewall? and lastly, is an advanced license of Notebook server required for this? Are any of the ArcPy modules required for the cloning process? We currently only have a standard server license. Any help on this topic is appreciated. 

Thanks. 

 

0 Kudos
11 Replies
DaveK
by
Occasional Contributor

That didn't seem to work as it threw the same results as before. Anything else I could be doing wrong? 

DaveK_0-1625149050340.png

 

0 Kudos
DaveK
by
Occasional Contributor

Good morning @ReeseFacendini

After some more research and playing around with Python scripts, I've come across one that worked for me. Here is the script: 

source = GIS("PORTAL URL", "PORTAL USERNAME", "PASSWORD", verify_cert=False)

target = GIS("https://arcgis.com", "AGO USERNAME")

#list all items in user account
sourceuser = "PORTAL USERNAME"
user = source.users.get(sourceuser)
items = user.items()
print("--> Root")
for item in items:
    print("\t{} : {} : {}".format(item.title, item.type, item.id))
folders = user.folders
for fld in folders:
    flditems = user.items(fld['title'])
    print("--> " + fld['title'])
    for item in flditems:
        print("\t{} : {} : {}".format(item.title, item.type, item.id))


#set item as variable
CloneItem = source.content.get("ITEM ID")
CloneItem

#clone the item
cloned_items = target.content.clone_items(items=[CloneItem])
for ci in cloned_items:
    display(ci)

 

I appreciate all your help with this! 

Thanks. 

0 Kudos