I can use the GIS module on our organization's Community Hub site.
rom arcgis.gis import GIS
gis = GIS("https://willcounty.maps.arcgis.com/", "user", "password")
But, I can't on ArcGIS Hub. This attempt is from an anaconda environment. I also tried from an Pro environment and got same error.
from arcgis.gis import GIS
gis = GIS("https://willcountygis.hub.arcgis.com/", "username", "password")
#Error:
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-5-0190cb412727> in <module>
1 from arcgis.gis import GIS
----> 2 gis = GIS("https://willcountygis.hub.arcgis.com/", "username", "password")
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\__init__.py in __init__(self, url, username, password, key_file, cert_file, verify_cert, set_active, client_id, profile, **kwargs)
481 )
482 else:
--> 483 raise e
484 try:
485 if (
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\__init__.py in __init__(self, url, username, password, key_file, cert_file, verify_cert, set_active, client_id, profile, **kwargs)
442 trust_env=kwargs.get("trust_env", None),
443 timeout=self._timeout,
--> 444 proxy=kwargs.get("proxy", None),
445 )
446 if self._portal.is_kubernetes:
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\_impl\_portalpy.py in __init__(self, url, username, password, key_file, cert_file, expiration, referer, proxy_host, proxy_port, connection, workdir, tokenurl, verify_cert, client_id, custom_auth, token, **kwargs)
203 )
204 # self.get_version(True)
--> 205 self.get_properties(True)
206
207 def add_group_users(self, user_names, group_id, admin_names):
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\_impl\_portalpy.py in get_properties(self, force)
1225 ) # issue seen with key, cert auth
1226 if not resp:
-> 1227 raise e
1228
1229 if resp:
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\_impl\_portalpy.py in get_properties(self, force)
1205 resp = None
1206 try:
-> 1207 resp = self.con.post(path, self._postdata(), ssl=True)
1208 except Exception as e:
1209 if (
c:\ProgramData\Anaconda3\envs\py37\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in post(self, path, params, files, **kwargs)
964 params.pop("token", None)
965 # pass
--> 966 elif token_as_header == False and self.token is not None: # as ?token=
...
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
According to the GIS Module help docs it doesn't look like you can access Hub. Is there any other way?
GIS : represents the GIS, either ArcGIS Online or an ArcGIS Portal
Solved! Go to Solution.
@JaredPilbeam2you are running into an error because you are signing into your Hub site. You need to sign into your Hub organization (as you have shown in the first code snippet) and then access your sites using the gis.hub submodule of the ArcGIS API for Python.
Alternatively, you can also use Hub's Python API https://github.com/Esri/hub-py/ but you will still need to sign into your Hub (org) and then fetch the particular site you wish to work with.
I also cannot access the ArcGIS Hub. Maybe its a glitch. Hopefully, it will get right soon.
The web page for hub.arcgis.com has no meaning to me, it says it will "allow people ... to accomplish ... goals"
Hard to get excited enough to try logging in.
I tried anyway -- I can log in fine using my AGO credentials in a browser but via arcgis.gis fails for me too.
Is Hub just a different UI for AGO?
No, it's meant to be a more collaborative environment than AGOL. Hub overview.
Sorry I was not clear -- the real question is, isn't it just exposing the content in your *.maps.arcgis.com account? So if you want to manipulate your content then you can use the regular AGOL login and its API. If there are very specific things that hub gives you beyond a different UI, then you'd be out of luck.
STOP READING HERE. 🙂
When I tried Hub I was shown content in my AGOL account, in a different format, shrugged, and moved on because I still had not "transformed my community" and it was already Wednesday.
The Hub Overview is the one I referenced above but thanks, I need more than that. Whoever designed it had no idea what Hub is, so they turned the crank on the hype machine and cranked out content-free sentences like "With ArcGIS Hub, organizations can leverage their existing data and technology and work together with internal and external stakeholders to track progress, improve outcomes, and create vibrant communities."
Excuse me now, I have to go get me some leverage, my community is insufficiently vibrant.
@JaredPilbeam2you are running into an error because you are signing into your Hub site. You need to sign into your Hub organization (as you have shown in the first code snippet) and then access your sites using the gis.hub submodule of the ArcGIS API for Python.
Alternatively, you can also use Hub's Python API https://github.com/Esri/hub-py/ but you will still need to sign into your Hub (org) and then fetch the particular site you wish to work with.
Hi @ManushiMajumdar ,
I have no problems accessing sites on our organization's Hub Community using either module here:
from arcgis.gis import GIS
gis = GIS("https://willcounty.maps.arcgis.com", "adminUsername", "password")
sites = str(gis.content.search(query="", item_type="Site", sort_order="asc"))
or
from arcgishub import hub
myHub = hub.Hub("https://willcounty.maps.arcgis.com", "adminUsername", "password") # or the url of your ArcGIS Online organization
initiatives = myHub.initiatives.search()
They both give me the same sites:
[<Initiative title:"Capital Project Tracking" owner:WillCoHub>,
<Initiative title:"testDelete" owner:jpilbeam_hub>,
<Initiative title:"DeciPH-ER " owner:WillCoHub>]
you are running into an error because you are signing into your Hub site.
That's what I'm after is our stuff on the Hub site: https://hub.arcgis.com. Is that possible with the Python API? That's my question. We have 900+ items.
To access all the items in your Hub (organization), you will need to use the `gis.content` submodule of the ArcGIS API for Python.
Yes, unless I'm completely missing something I can not access the content on our https://hub.arcgis.com page using any module or submodule.