ArcGIS API for Python: clone_items error

4717
12
03-26-2019 12:24 PM
AlanTabbernor
New Contributor

Hello,

I am trying to use clone_items for ArcGIS API for Python.  I am trying to clone a map to another AGOL folder which should copy the map and all dependent items to the specified folder.  This works for other maps in my content but it is failing for the specific map I need to copy today.  Does anyone know why this would be failing?  I get the following error(s).

Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1913, in clone
self._add_features(new_layers, relationships, layer_field_mapping, feature_service.properties['spatialReference'])
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1281, in _add_features
object_id_mapping[layer_id] = {layer_features['attributes'][object_id_field] : add_results['objectId'] for i in range(0, len(layer_features))}
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1281, in <dictcomp>
object_id_mapping[layer_id] = {layer_features['attributes'][object_id_field] : add_results['objectId'] for i in range(0, len(layer_features))}
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "r:\GIS_Warehouse\Production\Projects\CVRP\Scripts\promoteAGOL.py", line 107, in <module>
main()
File "r:\GIS_Warehouse\Production\Projects\CVRP\Scripts\promoteAGOL.py", line 92, in main
successItems = ag.content.clone_items(cloneArray, folder=promoteFolder, search_existing_items=False)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\gis\__init__.py", line 4034, in clone_items
return deep_cloner.clone()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 676, in clone
results = executor.submit(self._clone, executor).result()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\_base.py", line 432, in result
return self.__get_result()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 663, in _clone
raise ex
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1922, in clone
raise _ItemCreateException("Failed to create {0} {1}: {2}".format(original_item['type'], original_item['title'], str(ex)), new_item)
arcgis._impl.common._clone._ItemCreateException: ('Failed to create Feature Service xxx: list index out of range', <Item title:"xxx" type:Feature Layer Collection owner:xxx>)

0 Kudos
12 Replies
EarlMedina
Esri Regular Contributor

Hi Alan,

It sounds like a process of elimination might be the best approach. There's nothing too revealing in the errors. It sounds like if you clone another Web Map with the Stamen Base Map that it succeeds?

-Earl

0 Kudos
AlanTabbernor
New Contributor

Hi Earl,

Yes, it does succeed.  In fact the purpose of this clone_items script is to create a backup of this particular map and associated feature layers.  If I clone a map that was previously backed up a few weeks ago it succeeds.  I have now made a few changes to my 'master copy' map and wish to back it up again.  This is the map for which it fails.

These two maps are therefore almost exactly the same.  There has been minor updates made to the data (feature layers), one new feature layer added, and some small changes to things like pop-ups, etc.

-Alan

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Have you tried another way to do it? If you like, you can try copying the items:

https://developers.arcgis.com/python/sample-notebooks/clone-portal-users-groups-and-content/#Copy-It...

The above script might give you more granular control over the whole process when compared to clone_items.

I cloned my whole portal into a staging environment using 4 python scripts (copy the users, groups, items and reconstruct the relationships).  

0 Kudos