<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error connecting to ArcGIS Server with ArcGIS python API in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/error-connecting-to-arcgis-server-with-arcgis/m-p/869042#M5602</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This issue is with the ArcGIS API for Python 1.6.1+.&amp;nbsp; It appears that portalpy.py was only tested against AGOL and Portal not test ArcGIS Server.&amp;nbsp; I created a python clone using ArcGIS Pro and was able to make a few modification to get it working for 1.6.1..&amp;nbsp; I could send you my portalpy.py and connection.py modules with my changes.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main issue is with ...\impl\portalpy.py.&lt;/P&gt;&lt;P&gt;In the Portal class __init__ I added an additional check (lines 114 &amp;amp; 115) to check the url for an ArcGIS server and replaced line 118 (commented out) with line 117.&amp;nbsp; Line 118 is the main issue - if none of the url strings are found it just assumes it's a Portal url.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475853" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/475853_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also added an additional check (see below screen capture) to check the url for an ArcGIS Server "/arcgis/rest/" style url.&amp;nbsp; I had to do this because the "all_ssl" parameter needed to be False in my case.&amp;nbsp; Again this whole block between 139 and 182 (note comment on 139) just assumed we're connecting to AGOL or Portal.&amp;nbsp; My added lines 154-168 using the normalized_url are a total hack because self._is_arcpy (line 140) only allows 2 options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG __jive_id="475854" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/475854_pastedImage_2.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also had to inject a couple of lines in the get_properties function (lines 1095- 1097) to support a 'SERVER' connection with no ssl or token.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475855" class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/475855_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made a modification to ...\impl\connection.py to include support for a server (lines 650 - 651)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475856" class="jive-image image-4" src="https://community.esri.com/legacyfs/online/475856_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally there was one minor modification required in ...\gis\__init__.py (lines 451-453).&amp;nbsp; There is a product version check for portal but this throws an error for server.&amp;nbsp; Again this code assumes your only connecting to AGOL or Portal.&amp;nbsp; The weird thing is _product_version is never used anywhere in the code so commenting it out has no impact.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475857" class="image-5 jive-image" src="https://community.esri.com/legacyfs/online/475857_pastedImage_5.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you implement these modification in your clone you'll need to call GIS including the "verify_cert=False"&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_gis_server = GIS(_service_url, _user_name, _pass_word, verify_cert=False)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget that you'll need to run your script using your clone&lt;/P&gt;&lt;P&gt;"...\arcgispro-py3-clone\python.exe" myscript.py&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps someone&amp;nbsp;- Allen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Dec 2019 18:33:31 GMT</pubDate>
    <dc:creator>AllenCousins</dc:creator>
    <dc:date>2019-12-10T18:33:31Z</dc:date>
    <item>
      <title>Error connecting to ArcGIS Server with ArcGIS python API</title>
      <link>https://community.esri.com/t5/developers-questions/error-connecting-to-arcgis-server-with-arcgis/m-p/869041#M5601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am getting the following error with connecting to ArcGIS Server 10.4 using the arcgis python api 1.6.2 with python 3.6.6: &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class=""&gt;UnboundLocalError&lt;/SPAN&gt;: local variable 'resp' referenced before assignment

Is there a fix for this issue? 

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 17:01:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/error-connecting-to-arcgis-server-with-arcgis/m-p/869041#M5601</guid>
      <dc:creator>GilroyD_silva</dc:creator>
      <dc:date>2021-12-12T17:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error connecting to ArcGIS Server with ArcGIS python API</title>
      <link>https://community.esri.com/t5/developers-questions/error-connecting-to-arcgis-server-with-arcgis/m-p/869042#M5602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This issue is with the ArcGIS API for Python 1.6.1+.&amp;nbsp; It appears that portalpy.py was only tested against AGOL and Portal not test ArcGIS Server.&amp;nbsp; I created a python clone using ArcGIS Pro and was able to make a few modification to get it working for 1.6.1..&amp;nbsp; I could send you my portalpy.py and connection.py modules with my changes.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main issue is with ...\impl\portalpy.py.&lt;/P&gt;&lt;P&gt;In the Portal class __init__ I added an additional check (lines 114 &amp;amp; 115) to check the url for an ArcGIS server and replaced line 118 (commented out) with line 117.&amp;nbsp; Line 118 is the main issue - if none of the url strings are found it just assumes it's a Portal url.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475853" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/475853_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also added an additional check (see below screen capture) to check the url for an ArcGIS Server "/arcgis/rest/" style url.&amp;nbsp; I had to do this because the "all_ssl" parameter needed to be False in my case.&amp;nbsp; Again this whole block between 139 and 182 (note comment on 139) just assumed we're connecting to AGOL or Portal.&amp;nbsp; My added lines 154-168 using the normalized_url are a total hack because self._is_arcpy (line 140) only allows 2 options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG __jive_id="475854" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/475854_pastedImage_2.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also had to inject a couple of lines in the get_properties function (lines 1095- 1097) to support a 'SERVER' connection with no ssl or token.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475855" class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/475855_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made a modification to ...\impl\connection.py to include support for a server (lines 650 - 651)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475856" class="jive-image image-4" src="https://community.esri.com/legacyfs/online/475856_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally there was one minor modification required in ...\gis\__init__.py (lines 451-453).&amp;nbsp; There is a product version check for portal but this throws an error for server.&amp;nbsp; Again this code assumes your only connecting to AGOL or Portal.&amp;nbsp; The weird thing is _product_version is never used anywhere in the code so commenting it out has no impact.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="475857" class="image-5 jive-image" src="https://community.esri.com/legacyfs/online/475857_pastedImage_5.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you implement these modification in your clone you'll need to call GIS including the "verify_cert=False"&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_gis_server = GIS(_service_url, _user_name, _pass_word, verify_cert=False)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget that you'll need to run your script using your clone&lt;/P&gt;&lt;P&gt;"...\arcgispro-py3-clone\python.exe" myscript.py&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps someone&amp;nbsp;- Allen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:33:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/error-connecting-to-arcgis-server-with-arcgis/m-p/869042#M5602</guid>
      <dc:creator>AllenCousins</dc:creator>
      <dc:date>2019-12-10T18:33:31Z</dc:date>
    </item>
  </channel>
</rss>

