Hello folks
Have you seen this annoying message when displaying a map in the Jupyter Lab/notebook:
In the browser console:
My GIS environment is ArcGIS Portal 10.6 with federated ArcGIS servers, IWA authentication.
If I connect to AGOL, there will be no warnings. So I think my jupyter environment should be fine, it's on the GIS side...
All advises and comments are welcome
I still have this issue, and I am also getting the following Error when trying to create a FeatureLayerCollection:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _hydrate(self)
8994
-> 8995 self._refresh()
8996
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _refresh(self)
8961 else:
-> 8962 dictdata = self._con.post(self.url, params, token=self._lazy_token)
8963
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers)
1158
-> 1159 self._handle_json_error(resp_json['error'], errorcode)
1160 return None
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in _handle_json_error(self, error, errorcode)
1179 errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
-> 1180 raise RuntimeError(errormessage)
1181
RuntimeError: Token Required
(Error Code: 499)
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _hydrate(self)
9003 self._lazy_token = None
-> 9004 self._refresh()
9005
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _refresh(self)
8961 else:
-> 8962 dictdata = self._con.post(self.url, params, token=self._lazy_token)
8963
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers)
1158
-> 1159 self._handle_json_error(resp_json['error'], errorcode)
1160 return None
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in _handle_json_error(self, error, errorcode)
1179 errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
-> 1180 raise RuntimeError(errormessage)
1181
RuntimeError: Token Required
(Error Code: 499)
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
<ipython-input-20-d415c0042ac8> in <module>
----> 1 flc = FeatureLayerCollection.fromitem(disrupt_tenancies1617)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in fromitem(cls, item)
8952 if not item.type.lower().endswith('service'):
8953 raise TypeError("item must be a type of service, not " + item.type)
-> 8954 return cls(item.url, item._gis)
8955
8956 def _refresh(self):
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py in __init__(self, url, gis)
1519
1520 try:
-> 1521 if self.properties.syncEnabled:
1522 self.replicas = SyncManager(self)
1523 except AttributeError:
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in properties(self)
8970 return self._lazy_properties
8971 else:
-> 8972 self._hydrate()
8973 return self._lazy_properties
8974
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _hydrate(self)
9011 # try token in the provided gis
9012 self._lazy_token = self._con.token
-> 9013 self._refresh()
9014
9015 if err is not None:
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py in _refresh(self)
8960 dictdata = self._con.get(self.url, params, token=self._lazy_token)
8961 else:
-> 8962 dictdata = self._con.post(self.url, params, token=self._lazy_token)
8963
8964 self._lazy_properties = PropertyMap(dictdata)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers)
1157 verify_cert=verify_cert, is_retry=True)
1158
-> 1159 self._handle_json_error(resp_json['error'], errorcode)
1160 return None
1161
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\_impl\connection.py in _handle_json_error(self, error, errorcode)
1178
1179 errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
-> 1180 raise RuntimeError(errormessage)
1181
1182 class _StrictURLopener(request.FancyURLopener):
RuntimeError: Token Required
(Error Code: 499)
and I can't get layers or tables for hosted Feature Service.
It will be really good if I can get a hint from one of the API insiders
I was told the error 499 is related to a bug:
#BUG-000109779 ArcGIS API for Python is unable to access hosted feature layers in Portal with Integrated Windows Authentication configured, unless the layer is shared with 'Everyone'
The error message in the map is a separate issue, although it is related to authentication also.
simo xu In regards to your error message in the map widget: Does your Enterprise have CORs enabled? Are you using the most up-to-date Python API? I've tested the most recent Enterprise against the most recent Python API and the CORs is working fine in my case, but there are a lot of moving parts for web authentication.
If you're looking for a quick workaround, serving your notebooks locally over https will provide a fix to any CORs issue. But it should be possible to interact with the notebook over http since ArcGIS Enterprise supports CORs.
David Vitale Thank you for your attention to this issue.
We left all CORs settings in our portal and ArcGIS Servers to the default value, and according to ESRI document, the default settings should allow CORs.
I also tried to serve the notebook over https (using a self-signed certificate), but the warning on the map widget remains. plus, I can't add any hosted feature layer to the map widget either. and I am not sure if these symptoms are linked back to the same cause.
Despite our setting is IWA authentication, ESRI support suggests me explicitly login my portal using my username and password like this due to a bug.
dcsiportal=GIS(url="https://portal_url",username="simo@DomainName")
This allows me to access the data in the private hosted feature layers, but these layers still can't be added to the map widget.
Thanks
Thanks for the info simo xu . I'll try to set up an IWA portal and add private features to a map, see if I can reproduce your error.
One last question for you: are you on v1.6.0 of the Python API? We added an IWA widget authentication fix that just made it into v1.6.0 of the Python API, using that version could potentially fix your issue.
Hi David
The latest version 1.6.0 seems fixed it, no more error message in the map widget and I can add layers to the map! magic
Only one thing I'd like to bring to your attention is that I still have to provide my username and password to login my portal, otherwise I can't access data in the hosted feature layers, for example if I want to use Spatially Enabled Dataframe (SEDF) to do the analysis. According to the online document, I should omit my username and password when the portal is using IWA authentication. Not a big deal, just in case this is an oversight in the document or in the API itself.
Thank you for your help.
Simo
Did anyone ever figure this out? I'm using Notebooks in Pro and get this error. And I can't add any data to the map.
This may or may not be helpful... I experience this issue in ArcPro Notebook (i.e. not an ArcGIS Online Notebook). It seems that using "pro" auth in an ArcPro Notebook causes the issue (unclear why). Just using gis=GIS() results in no error message for me in ArcPro.
It doesn't solve my problem though, as I need to authenticate into my organization.