arcgis-python-api
arcgis-python-api copied to clipboard
Disable/bypass Proxy to access ArcGIS Portal using Python API
Hello, I need to disable/bypass proxy in ArcGIS.
Here are details for this. My Computer's local server domain is "example.com". I installed ArcGIS Enterprise portal and web adaptor on this computer. It is possible to access the portal using https://example.com/arcgis on browser without any proxy configuration. But I can't access to the portal using arcgis python api. I installed Anaconda and arcgis-python-api package. (I didn't do this on ArcGIS Pro or ArcGIS notebook) I am using ArcGIS Enterprise, not ArcGIS online.
I tried to do a few things but keep getting this error.
-
gis = GIS(url="example.com", username=<username>, password=<password>, verify_cert="example.crt", proxy_host="127.0.0.1", proxy_port=80)
-
gis = GIS(url="example.com", username=<username>, password=<password>, verify_cert="example.crt", proxy=None)
-
gis = GIS(url="example.com", username=<username>, password=<password>, verify_cert="example.crt")
This command is working on windows CMD
ping example.com
I tried to access using python requests module.
import requests
try:
response = requests.get("https://example.com/arcgis", verify="example.crt")
if response.status_code == 200:
print("Success", response)
else:
print("False", response)
except Exception as e:
print(f"Error: {str(e)}")
When I ran this code, I got the same error. But I could get success response by disable/bypass proxy bypass according to this. https://stackoverflow.com/questions/28521535/requests-how-to-disable-bypass-proxy
import requests
session = requests.Session()
session.trust_env = False
try:
response = session.get("https://example.com/arcgis", verify="example.crt")
if response.status_code == 200:
print("Success", response)
else:
print("False", response)
except Exception as e:
print(f"Error: {str(e)}")
Based on this, I think I should disable/bypass proxy in GIS function, too. But I couldn't find an option for it. I tried to use only proxy=None but it got the same error. Please advice me. Thank you.
You can try using the trust_env=True
on the GIS
Closed to due inactivity. Please reopen if needed.