I need to migrate many Experience Builder Developer applications to our new Enterprise Portal and thought I found a somewhat automated approach using ArcGIS API for Python. https://developers.arcgis.com/python/latest/guide/experience-builder-workflows/
The upload function, however, is throwing an error and I can't make any sense of it. Here is the code:
from arcgis.apps.expbuilder import WebExperience
from arcgis.gis import GIS
#Establish a GIS connection to the target portal.
target_portal = GIS("https://gistest.name.com/portal", "myuser.name")
print(target_portal)
Enter password: ········
GIS @ https://gistest.name.com/portal version:2024.1
# pass in a path to a local config.json when instantiating experience
local_path = r"C:\WebDev\EBv1.16\downloaded-apps\myexbapp\cdn\3\config.json"
local_exp = WebExperience(gis=target_portal, path=local_path)
local_exp.datasources
Output {'dataSource_2': {'id': 'dataSource_2', 'type': 'WEB_MAP', 'sourceLabel': 'Fish Range Search Map', 'itemId': '0f727a3fa60c42bea404xxxxxx', 'portalUrl': ......}
new_item = local_exp.upload(
gis=target_portal,
publish=False,
title="Fish Range Finder Test",
auto_remap=True)
new_item
throws error:
NameError Traceback (most recent call last)
In [49]:
Line 1: new_item = local_exp.upload(
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\expbuilder\expbuilder.py, in upload:
Line 783: test_gis = GIS(url=url)
NameError: name 'GIS' is not defined
---------------------------------------------------------------------------
Can anyone tell me what I am doing wrong here? I don't know what 'GIS' name the error is referring to. The GIS module is defined and if it wasn't I would be getting an error in the first code block.