Since I can't see your URLs, I'm going to assume that is the issue.
url = "http://mysite.com/server" # So it's net location / web adapter
gis = GIS(url="http://mysite.com/portal", username="******", password='*******')
sd = ServicesDirectory(url=url, portal_connection=gis)
Even though this will work, accessing a server this way is not recommended. You would go through your GIS object instead since your site is federated.
myservers = gis.admin.servers.list()
It will return an array of server objects.
Thanks for the response.
Sorry for my lack of clarity. The URLs were okay, I just left them out as they are internal.
My objective was to get lists of services in a folder on the server and then gather some further information on them.
I thought the ServicesDirectory.list(folder="abc") method looked like an easy method in the API docs.
But any reference to 'folder' in any ServicesDirectory methods throws an error. That seems to have been around for a few versions.
I did remove the connection through the federated "gis" connection as you suggested though.
Ben Holmes Have you found a resolution for this? I've experienced it from v1.2.3 - 1.4.1.
What is wrong with this code?
url = "https://<servername>.spokanecounty.org:6443/arcgis/admin/" servDirectory = server.catalog.ServicesDirectory(url,<User>,<Pw>) servDirectory.folders
Results in this traceback:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\server\catalog.py", line 259, in folders
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_mixins.py", line 340, in __getitem__
Phil Larkin, Ben Holmes since the objective is to get a list of `Service` objects in each folder, please refer to the doc here: Managing your GIS servers | ArcGIS for Developers In short below should work in version `1.4.1`
server1.services.list() # to get list of services in root server1.services.folders # to get list of folders server1.services.list(folder='System') # to get services in a particular folder
Hi Atma, thanks for your reply.
I'm attempting to access the ServicesReport REST endpoint on a local enterprise server. Using the arcgis.gis.server module offers the ServicesDirectory.report function. It doesn't appear to me that the arcgis.gis.admin module has any applicable functions. Can you tell me how i would use the admin module to get to the ServicesReport end point?
from arcgis.gis import server url = "https://<servername>.spokanecounty.org:6443/arcgis/admin" srv = server.Server(url=url, username= <username>, password = <password>) srvManager = srv.services for folder in srvManager.folders: for service in srv.services.list(folder): summary = service.statistics['summary'] status = service.status
I experienced the same error and found that the methods and properties of ServicesDirectory didn't work with a url from Server 10.4 was used. BUT It worked with a url from 10.6. Could this be a bug Atma Mani ? Is ArcGIS API for Python only for versions > 10.5?