HOW TO
When working with a standalone ArcGIS Server server, it is possible to connect to the server, find a service by its name, and delete the service using ArcGIS API for Python. This common administrative process can be automated by using the gis.server Python module via the portal when it is federated with the server.
To access and delete items on a standalone server using the ArcGIS API for Python gis.server module, refer to the following workflow:
import arcgis from arcgis import * from arcgis.gis import server
s = server.Server("<SERVERURL>/admin",username='<adminuser>',password='<adminpass>')
cdir = s.content
serv = cdir.get("<SERVICE NAME>",folder = "<FOLDER>")
serv.service.delete()
If the process is successful, the system returns True at the end of the code. If the item cannot be deleted, the system returns False instead. The following is the full sample script:
import arcgis from arcgis import * from arcgis.gis import server s = server.Server("<SERVERURL>/admin",username='<adminuser>',password='<adminpass>') cdir = s.content serv = cdir.get("<SERVICE NAME>",folder = "<FOLDER>") serv.service.delete()
Get help from ArcGIS experts
Download the Esri Support App