'str' object has no attribute

9712
6
Jump to solution
04-30-2021 03:55 PM
CherylCollins
New Contributor III

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.

CherylCollins_0-1619823071698.png

 

 

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

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)

 

View solution in original post

6 Replies
by Anonymous User
Not applicable

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)

 

CherylCollins
New Contributor III

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.

0 Kudos
JoshSender2
New Contributor II

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!

0 Kudos
CherylCollins
New Contributor III
Unfortunately, I never got the whole thing to work. I ended up buying to two one-month subscriptions to Admin Tools so I could finally copy over the Story Maps, and even that was not without its problems. I think ESRI really needs to make it easier to transfer Story Maps between organizations. We could be designing great stuff for our clients, but it's not happening.
JoshSender2
New Contributor II

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!

0 Kudos
Tim_McGinnes
Occasional Contributor III

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)

 

 

0 Kudos