AnsweredAssumed Answered

Unable to connect to ArcGis Enterprise Portal via python using token

Question asked by sigu on Oct 23, 2019
Latest reply on Sep 18, 2020 by L.Mishra_networkrail



I want to connect to our ArcGis Entreprise portal in a python script using a valid token, but it fails ....

I execute this script from ArcGis Pro connected to our portal.


#My script "Script"

import arcgis.gis
import arcgis.gis.admin
import arcgis.gis.server


ent_gis = arcgis.gis.GIS(url=arcpy.GetActivePortalURL(),token=arcpy.GetSigninToken())






Start Time: mercredi 23 octobre 2019 15:01:01
Running script Script...
Failed script Script...
 Traceback (most recent call last):
  File "C:\Users\freval-s\Documents\ArcGIS\Projects\MyProject5\", line 6, in <module>
    ent_gis = arcgis.gis.GIS(url=arcpy.GetActivePortalURL(),token=arcpy.GetSigninToken())
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\", line 381, in __init__
    self._lazy_properties = PropertyMap(self._portal.get_properties(force=force_refresh))
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\", line 1088, in get_properties
    if resp:
UnboundLocalError: local variable 'resp' referenced before assignment
 Failed to execute (Script).
Failed at mercredi 23 octobre 2019 15:01:07 (Elapsed Time: 5,80 seconds)