<?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 Connect to ArcGIS Server using Python... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562390#M73244</link>
    <description>&lt;P&gt;I have a workflow where I update data on a nightly basis.&amp;nbsp; The same data that I am updating also feeds a web mapping service that is served up through ArcGIS Server (AGS) (10.7.1).&lt;/P&gt;&lt;P&gt;The issue that I am running into is that the service is putting a lock on my source data and therefore cannot update it.&lt;/P&gt;&lt;P&gt;I did find an article where you could turn off Lock Database Schema.&amp;nbsp; Instead of updating the feature class row by row I just recreate the feature locally and then overwrite the feature class that sits on our server.&amp;nbsp; Unfortunately, this did not prevent my feature class from still being locked.&lt;/P&gt;&lt;P&gt;&lt;A href="https://enterprise.arcgis.com/en/server/10.5/administer/windows/disabling-schema-locking-on-a-map-service.htm#:~:text=If%20your%20workflow%20requires%20periodic%20updates%20to%20the,schema%20locking%20using%20ArcGIS%20Server%20Manager%20or%20ArcMap." target="_blank" rel="noopener"&gt;Disable schema locking on a map service—ArcGIS Server Administration (Windows) | Documentation for ArcGIS Enterprise&lt;/A&gt;&lt;/P&gt;&lt;P&gt;When I manually stop the service, my script runs perfectly and the feature class in question is updated.&amp;nbsp; So naturally I started investigating how one would stop an AGS service using Python.&amp;nbsp; I came across the following article.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994" target="_blank" rel="noopener"&gt;How To: Stop GIS Services Using ArcGIS API for Python&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The problem that I encounter is that I cannot actually connect to my AGS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
import arcgis.gis.admin
gis = GIS("https://XYZ/MyWebAdaptor/admin", "MyLogin", "MyPassword", verify_cert=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get multiple errors all relating to a login error.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Exception: A general error occurred: Could not login. Please ensure you have valid credentials and set your security login question.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I used the exact same URL and login information to access my AGS in ArcGIS Pro.&amp;nbsp; I also use the same login information to login into AGS Manager.&lt;/P&gt;&lt;P&gt;I'm not sure what I am missing when I can use the same information to login multiple ways but when using python, it does not recognize the login.&lt;/P&gt;&lt;P&gt;Any assistance or suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;~DJB&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2024 19:58:29 GMT</pubDate>
    <dc:creator>DJB</dc:creator>
    <dc:date>2024-11-25T19:58:29Z</dc:date>
    <item>
      <title>Connect to ArcGIS Server using Python...</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562390#M73244</link>
      <description>&lt;P&gt;I have a workflow where I update data on a nightly basis.&amp;nbsp; The same data that I am updating also feeds a web mapping service that is served up through ArcGIS Server (AGS) (10.7.1).&lt;/P&gt;&lt;P&gt;The issue that I am running into is that the service is putting a lock on my source data and therefore cannot update it.&lt;/P&gt;&lt;P&gt;I did find an article where you could turn off Lock Database Schema.&amp;nbsp; Instead of updating the feature class row by row I just recreate the feature locally and then overwrite the feature class that sits on our server.&amp;nbsp; Unfortunately, this did not prevent my feature class from still being locked.&lt;/P&gt;&lt;P&gt;&lt;A href="https://enterprise.arcgis.com/en/server/10.5/administer/windows/disabling-schema-locking-on-a-map-service.htm#:~:text=If%20your%20workflow%20requires%20periodic%20updates%20to%20the,schema%20locking%20using%20ArcGIS%20Server%20Manager%20or%20ArcMap." target="_blank" rel="noopener"&gt;Disable schema locking on a map service—ArcGIS Server Administration (Windows) | Documentation for ArcGIS Enterprise&lt;/A&gt;&lt;/P&gt;&lt;P&gt;When I manually stop the service, my script runs perfectly and the feature class in question is updated.&amp;nbsp; So naturally I started investigating how one would stop an AGS service using Python.&amp;nbsp; I came across the following article.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994" target="_blank" rel="noopener"&gt;How To: Stop GIS Services Using ArcGIS API for Python&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The problem that I encounter is that I cannot actually connect to my AGS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
import arcgis.gis.admin
gis = GIS("https://XYZ/MyWebAdaptor/admin", "MyLogin", "MyPassword", verify_cert=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get multiple errors all relating to a login error.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Exception: A general error occurred: Could not login. Please ensure you have valid credentials and set your security login question.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I used the exact same URL and login information to access my AGS in ArcGIS Pro.&amp;nbsp; I also use the same login information to login into AGS Manager.&lt;/P&gt;&lt;P&gt;I'm not sure what I am missing when I can use the same information to login multiple ways but when using python, it does not recognize the login.&lt;/P&gt;&lt;P&gt;Any assistance or suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;~DJB&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 19:58:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562390#M73244</guid>
      <dc:creator>DJB</dc:creator>
      <dc:date>2024-11-25T19:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ArcGIS Server using Python...</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562428#M73246</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/465280"&gt;@DJB&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Try the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from arcgis.gis import server

# Stand-alone ArcGIS Server instance specify Primary Site Admin (i.e. siteadmin)
# Federated ArcGIS Server instance specify Portal Admin (i.e. portaladmin)
agsServer= server.Server(url="https://ags.esri.com/server", username='portaladmin', password='*******')

# Stop services
serviceList = []
folderList = [folder for folder in agsServer.content.folders if folder != 'Hosted'
              and folder != 'System' and folder != 'Utilities']
folderList.append('')
for folder in folderList:
    for service in agsServer.services.list(folder):
        service.stop()&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Nov 2024 21:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562428#M73246</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-11-25T21:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ArcGIS Server using Python...</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562442#M73247</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You did it again and solved my issue.&amp;nbsp; I tweaked your code slightly so that I am turning of the specific service in question.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;folderList.append('')
for folder in folderList:
    for service in agsServer.services.list(folder):
        if service.properties.serviceName == "Nutrient_Management_Application_Sites":
            service.stop()&lt;/LI-CODE&gt;&lt;P&gt;Thank you so much for your lightning quick response.&lt;/P&gt;&lt;P&gt;This is getting ridiculous.&amp;nbsp; I feel like I owe you big time for the number of times you've bailed me out.&lt;/P&gt;&lt;P&gt;Thanks again for all your help.&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 21:32:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-arcgis-server-using-python/m-p/1562442#M73247</guid>
      <dc:creator>DJB</dc:creator>
      <dc:date>2024-11-25T21:32:58Z</dc:date>
    </item>
  </channel>
</rss>

