arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Disable/bypass Proxy to access ArcGIS Portal using Python API

Open rockstarcoder333 opened this issue 1 year ago • 1 comments

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. image

  • 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 image

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)}")

image

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.

rockstarcoder333 avatar Sep 10 '23 19:09 rockstarcoder333

You can try using the trust_env=True on the GIS

achapkowski avatar Sep 18 '23 10:09 achapkowski

Closed to due inactivity. Please reopen if needed.

nanaeaubry avatar May 13 '24 10:05 nanaeaubry