Hey all,
I am currently working on a Python script and when I authenticate into AGOL I have no issues until I run certain queries and then I get:
'InsecureRequestWarning: Unverified HTTPS request is being made to host 'PORTALNAME.maps.arcgis.com'. Adding certificate verification is strongly advised.'
This specifically occurs when I add the max_item parameter in the gis.content.search method.
As an example, if I run the following, I get no warning:
wm_items = gis.content.search(query=query)
If I add that parameter, then the warning appears:
wm_items = gis.content.search(query=query, max_items=10000)
I authenticated using the GIS(api_key='...', referer='https') method.
Any help would be appreciated.
Solved! Go to Solution.
There's an issue out for it already:
InsecureRequestWarning · Issue #2164 · Esri/arcgis-python-api
Hey @tiztrain
This is just a warning currently, and shouldn't prevent you from running queries, I may have missed you saying that though. If you'd like to silence them, you can use the URLLIB library to do something like this here:
import warnings
from urllib3.exceptions import InsecureRequestWarning
warnings.simplefilter("ignore", InsecureRequestWarning)
On the end of your GIS connection string you can also try to add verify_cert=True.
I would try reducing the amount of max items as well, could be something happening there.
Cody
Thanks for getting back to me so quickly @CodyPatterson
It seems to not have prevented me from doing anything but I am cleaning up my code now and wanted to resolve this issue. I did see that I could hide it but was thinking that this message might be important and thought it was indicating that I was doing something wrong.
I was also wondering if reducing the max_items would fix it but even when I put it to 1, still got the same issue.
Tried auth by using what you suggested. Tell me if I am using it wrong but did the following but unfortunately that did not help:
GIS(api_key='...', referer='https', verify_cert=True)
I am getting these warnings also
There's an issue out for it already:
InsecureRequestWarning · Issue #2164 · Esri/arcgis-python-api
But how to ignore them? I mean ingnore in python. I know how to ignore warnings in python, but how for this case?
This post user says the same thing, and I ask the say question (but give an example of what I tried). 🙂
import warnings
from urllib3.exceptions import InsecureRequestWarning
warnings.simplefilter("ignore", InsecureRequestWarning)
print ('Warnings have been silenced')