clone_items 'NoneType' ojbect has no attribute 'metadata'

576
5
01-30-2024 05:34 PM
Labels (1)
ResourceAnalyst
New Contributor II

Hi,

I'm attempting to build a simple script to migrate an Experience Builder app from a development to production environment but receiving  'NoneType' ojbect has no attribute 'metadata' on the final line.

The item_to_migrate is an object and does have a valid metadata property unless that's not the problem here?

from arcgis.gis import GIS

portal_password = '***'
user = '***'

dev_gis = GIS("https://***/portal", user, portal_password)
prod_gis = GIS("https://***/portal", user, portal_password)

item_to_migrate = dev_gis.content.get("1ff4d32bc2344739b6b4e4df61f5de08")

clone_result = prod_gis.content.clone_items(items=[item_to_migrate],folder="Asset")

 

 

0 Kudos
5 Replies
hlindemann
New Contributor III

Hi @ResourceAnalyst, are you sure that you are getting an object back on your item_to_migrate?

Things to look out for:

  •  if your source data is not a hosted feature layer you have to first manually publish it in the destination
  • I would turn on preserve item id flag if it is enterprise.
  • also try to set the copy_data flag to false.

Hope it helps

Henry

 

ResourceAnalyst
New Contributor II

Thanks,

The source data is already published and I have added those 2 flags but the same error above remains. Object from VS Code as below:

{'_portal': <arcgis.gis._impl._portalpy.Portal object at 0x000002623EF78370>, '_gis': GIS @ https://
*.com.au/portal version:10.3, 'itemid': '1ff4d32bc2344739b6b4e4df61f5de08', 'thumbnail': None, '
_workdir': 'C:\\Users\\*\\AppData\\Local\\Temp\\2', '_hydrated': False, 'id': '1ff4d32bc2344739b6b4e
4df61f5de08', 'owner': '*', 'created': 1698098887072, 'isOrgItem': True, 'modified': 170666283
8039, 'guid': None, 'name': None, 'title': 'Assets', 'type': 'Web Experience', 'typeKeywords': ['EXB Exp
erience', 'JavaScript', 'publishVersion:1.10.0', 'Ready To Use', 'status: Published', 'version:1.10.0',
'Web Application', 'Web Experience', 'Web Mapping Application', 'Web Page', 'Web Site', 'Metadata'], 'de
scription': 'Test to see if metadata gets populated.', 'tags': ['asset'], 'snippet': 'Simple app to main
tain assets for Land Team', 'documentation': None, 'extent': [], 'categories': [], 'spatialReference': N
one, 'accessInformation': None, 'licenseInfo': None, 'culture': 'en-us', 'properties': None, 'advancedSe
ttings': None, 'url': 'https://*.com.au/portal/apps/experiencebuilder/experience/?id=1ff4d32
bc2344739b6b4e4df61f5de08', 'proxyFilter': None, 'access': 'shared', 'size': 132816, 'subInfo': 0, 'appC
ategories': [], 'industries': [], 'languages': [], 'largeThumbnail': None, 'banner': None, 'screenshots'
: [], 'listed': False, 'ownerFolder': '7c3df485a8ff438c8d01f4af2e19b066', 'protected': False, 'commentsE
nabled': False, 'numComments': 0, 'numRatings': 0, 'avgRating': 0, 'numViews': 44, 'itemControl': 'admin
', 'scoreCompleteness': 20, 'groupDesignations': None, 'lastViewed': -1, '_depend': <Dependencies for 1f
f4d32bc2344739b6b4e4df61f5de08>}

 

0 Kudos
hlindemann
New Contributor III

Hi @ResourceAnalyst, What version of portal do you have deployed? and can you add the track trace e.g. the error that you get from the script?

Other methods you can try to use is collaboration or try using the group migration manger 
arcgis.gis module | ArcGIS API for Python
is creates a package that you can import on the other system.

 

 

 

0 Kudos
ResourceAnalyst
New Contributor II

Thanks again,

Portal 11.1

Exception has occurred: AttributeError
'NoneType' object has no attribute 'metadata'
  File "R:\Applications\Scripts\GIS\ArcGIS Enterprise\CopyPortalItemSimple.py", line 26, in <module>
    clone_result = prod_gis.content.clone_items(items=[item_to_migrate],folder="Asset",copy_data=False,preserve_item_id=True)
AttributeError: 'NoneType' object has no attribute 'metadata'

 

0 Kudos
hlindemann
New Contributor III

Hi @ResourceAnalyst, I had a deep dive into this problem, and the only difference I can see is that your object does not look like it is correct, compared to one that I spun up, see below.

This might then suggest an API version problem for the ArcGIS API are you running your code out of ArcGIS Pro or a standalone instance, if standalone can you upgrade the ArcGIS Module if Pro which version are you running. 


{'id': '361dcd0c4bec47fab3dbc4eac861cb52', 'owner': 'portaladmin', 'created': 1706849601820, 'isOrgItem': True, 'modified': 1706849622438, 'guid': None, 'name': None, 'title': 'Untitled experience 2', 'type': 'Web Experience', 'typeKeywords': ['EXB Experience', 'JavaScript', 'Ready To Use', 'status: Draft', 'version:1.10.0', 'Web Application', 'Web Experience', 'Web Mapping Application', 'Web Page', 'Web Site'], 'description': None, 'tags': [], 'snippet': None, 'thumbnail': None, 'documentation': None, 'extent': [], 'categories': [], 'spatialReference': None, 'accessInformation': None, 'licenseInfo': None, 'culture': 'en-us', 'properties': None, 'advancedSettings': None, 'url': None, 'proxyFilter': None, 'access': 'private', 'size': 1490, 'subInfo': 0, 'appCategories': [], 'industries': [], 'languages': [], 'largeThumbnail': None, 'banner': None, 'screenshots': [], 'listed': False, 'ownerFolder': None, 'protected': False, 'commentsEnabled': False, 'numComments': 0, 'numRatings': 0, 'avgRating': 0, 'numViews': 0, 'itemControl': 'admin', 'scoreCompleteness': 16, 'groupDesignations': None, 'lastViewed': -1}

 

0 Kudos