Searching through the other messages hasn't helped me with this. I like to figure things out on my own, but I'm stumped. I copied the deep_copy_content part below from a technical article, and only changed item.title to itemid and switched "gis" and "gis2". Otherwise it's the same. "gis" is my target location.
Here's what I'm seeing. I appreciate any suggestions.
Solved! Go to Solution.
The clone_items function takes a list of Items. It seems like you are passing in the string item ids instead.
It looks like you didn't include the code that initializes the items array so I can't tell if that's the actual issue.
Try something like:
itemid = "xxxxx"
# Fetch item from gis
item = gis.content.get(itemid)
# Clone to gis2
gis2.content.clone_items([item], copy_date=True, search_existing_items=True)
The clone_items function takes a list of Items. It seems like you are passing in the string item ids instead.
It looks like you didn't include the code that initializes the items array so I can't tell if that's the actual issue.
Try something like:
itemid = "xxxxx"
# Fetch item from gis
item = gis.content.get(itemid)
# Clone to gis2
gis2.content.clone_items([item], copy_date=True, search_existing_items=True)
Got it! What worked was adding item = before gis.content.get and replacing copy_list with [item]. I also got an error message about copy_data=True, but I just deleted that and it worked. Thanks for the help. I'm attaching the whole final script. Tim_McGinnes also suggested part of the same answer.
I'm running into a similar error with my code attempting to do the same thing. @CherylCollins could you post your final code one more time? I'm curious if your last line of code is "deep_copy_content(items)" or "deep_copy_content(item)". Thanks so much!
Got it. Yeah that's possibly where I'm heading soon as well. I also have an open case with ESRI Support staff for this issue. If anything comes out of that, I'll be sure to update here. Thanks for the info!
It looks like you may have left out a crucial line from the script (Link) :
items = gis.content.get(itemid)
If gis is your target and gis2 is your source then it should be:
items = gis2.content.get(itemid)
Try the following:
from arcgis.gis import GIS
gis = GIS(<Put your URL here>) # Where it is going to
gis2 = GIS(<Put your URL here>) # Where it is coming from
itemid = '<Put your ID here>' # The item ID to clone
items = gis2.content.get(itemid)
def deep_copy_content(input_list):
for item in input_list:
try:
print("Cloning " + item.title)
copy_list = []
copy_list.append(item)
gis.content.clone_items(copy_list, copy_data=True, search_existing_items=True)
print("Successfully cloned " + item.title)
except Exception as e:
print(e)
print("The function has completed")
deep_copy_content(items)