Esri / Esri/arcgis-python-api

content.clone_items fails saying item_id exists already while content.get returns none for same item_id

Open
#1,486 1 comment 1 reaction 2 assignees Claimed by @achapkowski View on GitHub
bug
Dominant language
Python
Stars
2.2k
Forks
1.2k
Avg merge
2h 40m
Merged PRs (30d)
2

Description

**Describe the bug**
content.clone_items fails for an application saying that the item_id exists currently; however, a content.get call returns nothing for the same item_id.

**To Reproduce**
Steps to reproduce the behavior:
```python
import arcgis
import keyring

dev_admin_user = keyring.get_password("dev-portal", "dev-portal_admin")
dev_admin_pass = keyring.get_password("dev-portal", dev_admin_user)
prod_admin_user = keyring.get_password("prod-portal", "prod-portal_admin")
prod_admin_pass = keyring.get_password("prod-portal", prod_admin_user)

gis_dev = arcgis.gis.GIS(r"https://dev-data.prospertx.gov/portal", dev_admin_user, dev_admin_pass)
gis_prod = arcgis.gis.GIS(r"https://data.prospertx.gov/portal", prod_admin_user, prod_admin_pass)

dict_items_to_transfer = {
"app_cityworks_sso": "00dba4e70cfc4be0aa373d778e45ea7a",
"app_edit_grease_trap" : "235195a4c458400a8d1f20110001a46f",
"app_edit_plant_inventory": "95cd1ec9ec69459086996e77f9b6c198",
"app_fire_mapbook": "436f3be7736144a1bc50939208fa7e6d",
"app_imaps": "d5cc3805e88b4a86b468b61c32f5bb2d",
"app_speed_limits": "bb443aaf25c84ec3baa5310931af45e0",
"app_str_tracking": "06ab9fffe88d415a90e061f5fbd3a260",
"app_tax_permits": "9e64d3c40c414aadad3b39730130e907",
"app_thoroughfare_plan": "a1024d9ddcad42aa8b443f6e83a61158",
"map_edit_grease_trap": "edeab74f2ede48c9851b4ff8d162af2a",
"map_edit_plant_inventory": "677c386c8f06477298198c1882704152",
"map_fire_mapbook": "a6a324f03f7341089c1269ee5dbe2873",
"map_imaps": "a084d645ee4d42cfba4972cdd2d1a03e",
"map_nearmap": "ad27ac5788da4ee6931a6e01f3e37fce",
"map_speed_limits": "9d9c780caa494ed6a3382a284a4d8942",
"map_str_tracking": "872f2112e7e44df983bf28ed7ebb5e75",
"map_tax_permits": "d66c0d56873544ab978109b07b49b245",
"map_thoroughfare_plan": "6fda919d399049cbb25817e885e2b7f4"
}

for key, value in dict_items_to_transfer.items():
print(f"Transferring item id:\n\t{value} | has short name: {key}")
item_to_clone = gis_prod.content.get(value)
#print(item_to_clone.get_data())
try:
print(f"\tDoes it exist?\t{gis_dev.content.get(value)}")
gis_dev.content.clone_items(
items = [item_to_clone],
copy_data = False,
search_existing_items = True,
preserve_item_id = True
)
except Exception as e:
print(f"\tSomething went wrong:\n\t{e}\n----------")
pass
```
error:
```python
#user generated
Transferring item id:
235195a4c458400a8d1f20110001a46f | has short name: app_edit_grease_trap
Does it exist? None
Something went wrong:
#actual exception
("Failed to create Web Mapping Application Editing_PublicWorks_GreaseInterceptors: Item with Id '235195a4c458400a8d1f20110001a46f already exists[.\n](https://file+.vscode-resource.vscode-cdn.net/b%3A/Repository/Enterprise_Transfer/n)(Error Code: 400)", )
```
**Screenshots**
Script Output for Loop
![image](https://user-images.githubusercontent.com/12204584/223489252-e0ae54b2-b91f-4731-82c5-989de3112c8f.png)
User content page in `portal/sharing/rest/content/users` backend, shows no items that match items asserted to exist.
![image](https://user-images.githubusercontent.com/12204584/223489824-4b0c77b4-7580-4591-8e33-8eeb702b0a7c.png)

**Expected behavior**
If an item cannot be returned from `content.get()` then `content.clone_items()` should not assert that the item already exists.

**Platform (please complete the following information):**
- OS: Windows 11
- Browser: Chrome
- Python API Version: 2.1.0.2
- Source Portal (10.8.1) Target Portal (10.9.1)

**Additional context**
- When I first tried to copy the content over I had the `copy_data = True` and received lots of errors. I changed it to `copy_data = False` and was able to copy over maps but not apps.
- Performed a reconfigure and reindex as well to no effect:
```python
indexer = gis_dev.admin.system.indexer
indexer.reconfigure()
indexer.reindex(mode = "FULL_MODE")
```
- Searched for all items using `gis_dev.content.search(query="*", max_items=1000)` and did not return results with the problem items above.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.