Skip to content

Using clone_items(copy_data = False) on a WebMap containing a public view of another organisation's feature service fails due to lack of permissions. #2282

Open
@robmacg1

Description

@robmacg1

Describe the bug
As the title describes, gis.content.clone_items(copy_data = False) raises an exception due to lack of permissions when the WebMap being cloned contains references to a public view of another organisation's feature service. Setting copy_data to False should mean that data that the cloner doesn't own is referenced rather than copied and there shouldn't be a permissions issue.

To Reproduce
Steps to reproduce the behavior:

from arcgis.gis import GIS


# Public Web Map containing a reference to the feature service on the line below
TEMPLATE_WEB_MAP_ITEM_ID = '2638fcbe45dc421bb800af0ab9367818'
OTHER_ORGANISATION_FEATURE_SERVICE_ITEM_ID = '11ed3046a3df48b3af56048fbcd4b12a'

def main():
    gis = GIS('https://www.arcgis.com', username, password)

    template_webmap_item = gis.content.get(TEMPLATE_WEB_MAP_ITEM_ID)

    clone = gis.content.clone_items(
        [template_webmap_item],
        copy_data=False
        )   


    print(f'Cloned {template_webmap_item.title} to {clone[0].title}')


if __name__ == '__main__':
    main()

error:

  File "/workspaces/arcgis-dev-container/src/clone_storymaps.py", line 25, in main
    clone = gis.content.clone_items(
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/__init__.py", line 9194, in clone_items
    deep_cloner = clone._DeepCloner(
                  ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 138, in __init__
    self._create_graph()
  File "/usr/local/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 231, in _create_graph
    self._get_item_definitions(item)
  File "/usr/local/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 557, in _get_item_definitions
    self._get_item_definitions(feature_service)
  File "/usr/local/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 667, in _get_item_definitions
    properties = self._get_properties(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 311, in _get_properties
    and layer.manager
        ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/features/layer.py", line 304, in manager
    res = FeatureLayerManager(admin_url, self._gis, fl=self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/features/managers.py", line 3607, in __init__
    self._hydrate()
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/__init__.py", line 19690, in _hydrate
    self._refresh()
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/__init__.py", line 19641, in _refresh
    raise e
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/__init__.py", line 19630, in _refresh
    dictdata = self._con.post(
               ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1529, in post
    return self._handle_response(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1004, in _handle_response
    self._handle_json_error(data["error"], errorcode)
  File "/usr/local/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1027, in _handle_json_error
    raise Exception(errormessage)
Exception: User does not have permissions to access this service
User does not have permissions to access this service
(Error Code: 403)

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
I would expect that with the copy_items argument set to false, it is possible to clone a WebMap item that contains public data using ContentManager.clone_items() since it was possible to make the WebMap with those data in the first place.

Platform (please complete the following information):

  • OS: Linux
  • Browser [e.g. chrome, safari]
  • Python API Version: 2.4.1

Additional context
Add any other context about the problem here, attachments etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions