Select to view content in your preferred language

clone_items 'NoneType' ojbect has no attribute 'metadata'

1468
7
01-30-2024 05:34 PM
ResourceAnalyst
Emerging Contributor

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
7 Replies
hlindemann
Regular Contributor

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
Emerging Contributor

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
Regular Contributor

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
Emerging Contributor

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
Regular Contributor

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
BBowers_napacounty
Occasional Contributor

@ResourceAnalyst 

I am experiencing the same issue with clone_items() on Portal 11.1.

Did you ever find a solution? Thanks in advance for any suggestions!

0 Kudos
KeitherPerkinsWSB
Emerging Contributor

I have talked to ESRI support and their are known bugs for cloning all apps with the clone.items() function. I have been told there is no current work around or other functions that could be used on cloning Apps and these bugs will be addressed in the ArcGIS API Python 2.4 release. Which they do not have an official release date for but possibly October 2024.  

To me this makes all the documentation out there on cloning items irrelevant. 
https://developers.arcgis.com/python/guide/cloning-content/
https://developers.arcgis.com/python/guide/cloning-complex-apps/#web-experiences

 

0 Kudos