<?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 Stopping Service via Python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387339#M9687</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am using the code below to stop a service on ArcGIS Server. This work flawlessly on this particular server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to use this code on a service on a different server, I get a&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;KeyError: 'folders'&amp;nbsp;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;error on line 8. Not sure what this error is indicating.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Does anyone know why this would work on one server but not the other? Thanks!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
from arcgis.gis import server

s = server.Server("hhtps://server-url.com",username='username',password='password')

cdir = s.content

serv = cdir.get("Service Name",folder = "Folder")

serv.service.stop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2024 13:38:22 GMT</pubDate>
    <dc:creator>JoshBillings</dc:creator>
    <dc:date>2024-02-27T13:38:22Z</dc:date>
    <item>
      <title>Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387339#M9687</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am using the code below to stop a service on ArcGIS Server. This work flawlessly on this particular server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to use this code on a service on a different server, I get a&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;KeyError: 'folders'&amp;nbsp;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;error on line 8. Not sure what this error is indicating.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Does anyone know why this would work on one server but not the other? Thanks!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import *
from arcgis.gis import server

s = server.Server("hhtps://server-url.com",username='username',password='password')

cdir = s.content

serv = cdir.get("Service Name",folder = "Folder")

serv.service.stop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 13:38:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387339#M9687</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-27T13:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387340#M9688</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/26942"&gt;@JoshBillings&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you were to print s, cidr, and serv, would you get the expected results as the last server?&lt;/P&gt;&lt;P&gt;I assume what's happening is that the location of a folder may have changed or is not present within the directory listed.&lt;/P&gt;&lt;P&gt;Hope that help!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 13:44:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387340#M9688</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-02-27T13:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387354#M9689</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/712076"&gt;@CodyPatterson&lt;/a&gt;, thanks for the reply! I was able to print &lt;STRONG&gt;s&lt;/STRONG&gt; and &lt;STRONG&gt;cdir&lt;/STRONG&gt; and it was as expected. I can't get &lt;STRONG&gt;serv&lt;/STRONG&gt; printed because it's throwing an error on that line. Is there a way I can force print that even though there is an error?&lt;/P&gt;&lt;P&gt;I also double checked to make sure I had Service Name and Folder name spelled right and that it was actually on the server and it is.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 14:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387354#M9689</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-27T14:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387356#M9690</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/26942"&gt;@JoshBillings&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you happen to have a screenshot of the error that it's throwing? I may be able to look a little deeper into it!&lt;/P&gt;&lt;P&gt;It's good that everything else seems to be in order, we may just be down to one issue now!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 14:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387356#M9690</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-02-27T14:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387376#M9691</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/712076"&gt;@CodyPatterson&lt;/a&gt;- Screenshot is attached. In the screenshot it says "line 20" but that is referencing the&amp;nbsp;&lt;STRONG&gt;serv&lt;/STRONG&gt; variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 14:37:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387376#M9691</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-27T14:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387720#M9694</link>
      <description>&lt;P&gt;Is this running python code from Pro (3.x) or from ArcMap (2.7)?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 21:16:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387720#M9694</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2024-02-27T21:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387991#M9699</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10036"&gt;@MichaelVolz&lt;/a&gt;. I'm running this from Pro and it's using Python 3.9.18.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1387991#M9699</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-28T13:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388016#M9700</link>
      <description>&lt;P&gt;Hi Josh:&lt;/P&gt;&lt;P&gt;What version of Pro is that python version associated with?&lt;/P&gt;&lt;P&gt;I ask because I had a Pro python script that stopped GIS services that was working in Pro 2.x.&amp;nbsp; Unfortunately, the upgrade to Pro 3.x broke the script due to the architectural changes of Pro 3.x compared to 2.x with regards to security.&amp;nbsp; ESRI development has been looking into issue, but I have not heard back from ESRI if the issue has been resolved (It has been like this for 6 months).&lt;/P&gt;&lt;P&gt;Not sure if its the same exact issue, but both your script and my script were designed to stop services.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:34:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388016#M9700</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2024-02-28T13:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388061#M9701</link>
      <description>&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;I actually did recently upgrade Pro to 3.2. I was using 3.0.3 before. However, the script above will work for the other server in Pro 3.2, so it seems that may be an unlikely cause.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to use the code below to stop my services, but this stops &lt;STRONG&gt;all&lt;/STRONG&gt; services in a particular folder. I would still like to use my original code to stop specific services, so I'll still be looking into this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

# Set ArcGIS Server or Portal Instance
gis = GIS("https://server-url/portal", "username", "password", verify_cert=False)

# Get server list and return first server
serverList = gis.admin.servers.list()[0]

# Get list of Services in a specific folder
serviceList = serverList.services.list(folder="FolderName")

# Stop Services specified folder
print("Stopping Services...")
for service in serviceList:
     service.stop()
     
print("Services Stopped!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 14:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388061#M9701</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-28T14:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388067#M9702</link>
      <description>&lt;P&gt;One can stop specific services by using indexing on the "serviceList" variable.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

# Set ArcGIS Server or Portal Instance
gis = GIS("https://server-url/portal", "username", "password", verify_cert=False)

# Get server list and return first server
serverList = gis.admin.servers.list()[0]

# Get list of Services in a specific folder
serviceList = serverList.services.list(folder="FolderName")

# Get Specific Service through Index and Stop the Service
specificService = serviceList[0]
specificService.stop()&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 14:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1388067#M9702</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-02-28T14:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1538757#M10663</link>
      <description>&lt;DIV&gt;&lt;P&gt;Hello &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/26942"&gt;@JoshBillings&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;i use the service.properties.serviceName == "name_service" for a specific service name. I use this in a toolbox with multiples parameters the&amp;nbsp;&lt;STRONG&gt;service_name&lt;/STRONG&gt; = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;Hope this could help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;# arcpy.GetParameterAsText(4) =&amp;gt; &lt;STRONG&gt;folder_name&lt;/STRONG&gt; in arcgis server manager&lt;BR /&gt;services = server1.services.list(folder=arcpy.GetParameterAsText(4))&lt;BR /&gt;for &lt;/SPAN&gt;service &lt;SPAN&gt;in &lt;/SPAN&gt;services:&lt;BR /&gt;    &lt;SPAN&gt;if &lt;/SPAN&gt;service.properties.serviceName == service_name:&lt;BR /&gt;    service.stop()&lt;BR /&gt;    arcpy.AddMessage(service.status)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Sep 2024 00:39:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1538757#M10663</guid>
      <dc:creator>JohXENIE</dc:creator>
      <dc:date>2024-09-16T00:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping Service via Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1568655#M10966</link>
      <description>&lt;P&gt;These two articles helped me accomplish stopping and starting services programatically:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/managing-your-gis-servers/" target="_blank"&gt;https://developers.arcgis.com/python/latest/guide/managing-your-gis-servers/&lt;/A&gt;&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"&gt;https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 06:24:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/stopping-service-via-python/m-p/1568655#M10966</guid>
      <dc:creator>AndresCastillo</dc:creator>
      <dc:date>2024-12-14T06:24:22Z</dc:date>
    </item>
  </channel>
</rss>

