Select to view content in your preferred language

Exception: User folder not found (Error code: 400) using story.duplicate() via python api

970
7
03-05-2024 02:42 PM
Labels (1)
atmosfairy
Emerging Contributor

I have created a storymap template and shared it with a Shared Update group so that others can duplicate and populate the template by way of a semi-automated python tool. As the content owner, I can duplicate, update, save and share the template, but when others attempt to do the same, the aforementioned exception is thrown at sm.duplicate(). The result is a copy of the original template in the root folder (i.e. 'All My Content) of the user that cannot be opened or deleted. I could possibly ignore the error and move on, but would like to know if there is a better way of getting around this exception by defining a user folder; or something else? Any adivce appreciated. Note I am using arcgis 2.2.0. and ArcGIS Enterprise 10.9.1.

0 Kudos
7 Replies
ThePreatorian
Esri Contributor

Hi @atmosfairy, looks like you have a good use case for python.
I think I am able to reproduce on my end, but wanted to confirm the error you are seeing.
Are you getting a straight 400 error or the 404 error. Is there an additional message?

If you are willing, could you list the block types in your template story?



0 Kudos
atmosfairy
Emerging Contributor

Hi @ThePreatorian - Block types include: Storycover, Navigation, Sidecar (with map element and text nodes) and an image gallery.

Can confirm it is the Exception: User folder does not exist. (Error Code: 400)

Also, despite the creator not being able to open the item, when it is shared with the update group, I can see the item and open it successfully, even though I am not the owner of the new copy.

Further, the administrators also cannot view the duplicated item details, but can open and configure the storymap. However, any duplicated 'ghost' items cannot be deleted by owner or administrators - error message reads: 'Delete - The following items can't be deleted becasue they are delete protected or have dependent items'.

0 Kudos
ThePreatorian
Esri Contributor

@atmosfairy  have you tried creating the new StoryMap using copy_content? You could use this to copy all the content in your Template, into the new story.

Another thing you could try is to set permission inheritance for resources in the item that you can get with sm._item.resources.list():

for resourcedata in resources:
    resource_name = resourcedata['resource']
    if '.json' not in resource_name:
        existing_story._item.resources.get(resource_name, out_folder="/arcgis/home/")
    else:
        print(resource_name)
        resource_json = existing_story._item.resources.get(resource_name, try_json=True)
        with open(f"/arcgis/home/{resource_name}","w") as jsonfile:
            json.dump(resource_json, jsonfile)
    existing_story._item.resources.update(file=f"/arcgis/home/{resource_name}",properties={"access":"inherit"})




0 Kudos
atmosfairy
Emerging Contributor

Hi @ThePretotorian - thanks for getting back to me and sorry for the delayed response! Unfortunately, neither of these options work for me (for different reasons). I figured the simplest and most efficient work-around in this instance is to create multiple templates and reassign them to different users. If this is indeed a bug, I am happy to document the current workflow process, errors and traceback and log it through our administration account if that is best?

Thanks again 🖖

0 Kudos
ThePreatorian
Esri Contributor

@atmosfairy  Good to hear there is a workaround.

I know the python team released some improvements to the `duplicate`, `clone_items`, `copy_item` methods with the release of 2.3.0

You could consider upgrading to 2.3.0 and trying the workflow again


0 Kudos
atmosfairy
Emerging Contributor

Will do - hopeful the upgrade will improve the process as well as my mental health 🤣

0 Kudos
atmosfairy
Emerging Contributor

Will do - hopeful the upgrade will improve the process as well as my mental health 🤣

0 Kudos