Select to view content in your preferred language

Could not load service: MapServer

99
1
4 weeks ago
Labels (1)
Leandro-Zamudio
Frequent Contributor

Hi.

I'm trying to get a list of fields from all the services inside a folder in ArcGIS Server using Python API.

But when I want to list my services, all the MapServer gives Could not load service: <serviceURL>/MapServer

This is the code I'm using with a ServicesDirectory Object.

server_url = "https://<webadaptorserver>"
portal_url = "https://<webadaptorportal>"
usuario = "admin"
contraseña = "password"
gis = GIS(portal_url, usuario, contraseña)

gisSD= server.catalog.ServicesDirectory(url=server_url,tokenurl=gis._con.token)

servfolder="MYFOLDER"
servicios=gisSD.list(folder=servfolder)
for s in servicios:
    print (s)

 

0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor

Hi @Leandro-Zamudio ,

Try the following:

from arcgis.gis import server

# Variables
agsURL = 'dsn.domain.com/webadaptor'    # ArcGIS Server URL
username = 'portaladmin'    # Portal credentials if federated
password = '**********'
folder = 'Public'   # name of ArcGIS Server folder

# Connect to ArcGIS Server
agsServer = server.Server(url=f"https://{agsURL}", username=username, password=password)

# Iterate through services
for service in agsServer.services.list(folder):
    print(service)