Hi all,
I am in the process of migrating a Portal to another portal. I am using the clone_item() function to migrate the items unlike this clone users, groups, and content . This works great. The only issue I have is when I try to share items with groups, org or everyone. Although my script does update the sharing for some, I often get this error Item has a Relationship Type that does not allow this. (Error Code: 500).
Any idea what I can do to update sharing for an item and its related items?
Here is my current code:
#source content
source_users = source.users.search('!esri_ & !admin')
#target content
target_users = target.users.search('!esri_ & !admin & !system_publisher')
#source groups
source_groups = source.groups.search("!owner:esri_* & !Basemaps")
#target groups
target_groups = target.groups.search("!owner:esri_* & !Basemaps")
for user in source_users:
if user.username == "ITPublisher1":
tester_content = source.content.search("owner:"+ user.username, max_items=500)
for item in tester_content:
print(item.access)
if item.access == "shared":
for group in source_groups:
for group_item in group.content():
if group_item.itemid == item.itemid:
print(group)
target_group = target.groups.search(group.title)
for tg in target_group:
target_item = target.content.search(item.title)
print(tg.groupid)
for ti in target_item:
print(ti)
ti.share(everyone=False, org=False, groups=tg.groupid)
else:
print("not in target portal ")
#elif item.access == "public":
# target_item = target.content.search(item.title)
# for ti in target_item:
# print(ti)
# ti.share(everyone=True, org=False)
elif item.access == "org":
target_item = target.content.search(item.title)
for ti in target_item:
print(ti)
ti.share(everyone=False, org=True)