Greetings,
I am trying to loop through the Portal Gallery to get the itemId for all maps and/or apps.
I can get the itemId for a single app calling the item = xyz
e.g.
# item = "6f91e6d30e8b4776b23dccb2fc560c94"
# print(i['numViews'])
When I use the example in https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.apps.hub.html?highlight=itemid, get AttributeError: 'GIS' object has no attribute 'hub.id error.
import arcgis
from arcgis.gis import GIS
from arcgis import apps
from arcgis.apps import hub
url = "https://myarcgis.com/portal/home/gallery.html"
## https://myarcgis.com:7443/arcgis/home/content.html?start=1&view=grid&sortOrder=desc&sortField=modified&focus=applications-web&searchTerm=#organization
## url = "https://sslvwd1npxapp04.b-intra.net:7443/arcgis/home/content.html?sortOrder=desc&sortField=modified&focus=applications#organization"
### Make a connection to the portal
gis = GIS(url=url)
myHub = gis.hub
a_Initiative = myHub.initiatives.get('itemId *')
for i in a_Initiative:
print(I)
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" C:/Temp/DEV/GetPortalViewCounts.py
Traceback (most recent call last):
File "C:/Temp/DEV/GetPortalViewCounts.py", line 7, in <module>
from arcgis.apps import hub
ImportError: cannot import name 'hub'
Process finished with exit code 1
Regards,
Clive