Select to view content in your preferred language

gis.admin submodule only returns root level services

471
2
Jump to solution
07-14-2022 11:40 AM
ZacharyHart
Regular Contributor

Referencing this Esri How-To article, I am unable to return results from any server folder and I cannot seem to find documentation to access specific server folders.

  • ArcGIS Python API v2.01 Enterprise 10.9.1, federated.
  • The services in and folders are a mix of shared with everyone as well as content restricted to certain groups.
  • User logging in has full Admin privileges; also tried with primary site admin
  • tried accessing via portal URL and directly to Server Url; logins successful but only root level resources are returned.
  • Searching for content via something like gis.content.search(query="query stuff") returns Portal content no problem

Referencing this post here regarding specific folders, when I try the following (also marked as the solution):

 

 

serverFolder = 'My test folder'
serviceList = gis_servers.services.list(folder=serverFolder)

 

 

I receive a

 

 

'list' object has no attribute 'services'

 

 

The original Esri article also suggests that:

Note:
If the desired server folder array location is known in the list, the script can be modified to:

servers = gis.admin.servers.list()[0]

"[0]" can be modified to specify the exact location of the service in the array. In the example, the script grabs the first service in the list.

 Attempting that, the error is as follows:

 

AttributeError: 'tuple' object has no attribute 'services'

 

1 Solution

Accepted Solutions
Clubdebambos
Occasional Contributor III

Hi @ZacharyHart 

gis.admin.services.list() from the example in the link you provided returns a list of server objects. This is why you get the error 'list' object has no attribute 'services' because a Python list object does not have a 'services' property.

You need to reference a single server object within the server list returned and list the services in a folder for that particular server using the contents.list() to return a list of item objects.

from arcgis.gis import GIS

## access portal
portal = GIS("home")

## get list of servers as Server objects
## this line here takes a bit to run on my machine, a few minutes each time
gis_servers = portal.admin.servers.list()

## server of interest
## federated server is a Server object
federated_server = gis_servers[1]

## get list of folder contents
folder_contents = federated_server.content.list(folder="My_Folder"))

print(folder_contents)

 

~ learn.finaldraftmapping.com

View solution in original post

2 Replies
MichaelVolz
Esteemed Contributor

I have run into this issue as well, so I would be interested in learning how to solve this problem.

0 Kudos
Clubdebambos
Occasional Contributor III

Hi @ZacharyHart 

gis.admin.services.list() from the example in the link you provided returns a list of server objects. This is why you get the error 'list' object has no attribute 'services' because a Python list object does not have a 'services' property.

You need to reference a single server object within the server list returned and list the services in a folder for that particular server using the contents.list() to return a list of item objects.

from arcgis.gis import GIS

## access portal
portal = GIS("home")

## get list of servers as Server objects
## this line here takes a bit to run on my machine, a few minutes each time
gis_servers = portal.admin.servers.list()

## server of interest
## federated server is a Server object
federated_server = gis_servers[1]

## get list of folder contents
folder_contents = federated_server.content.list(folder="My_Folder"))

print(folder_contents)

 

~ learn.finaldraftmapping.com