Hi Everyone,
Our team are trying to create a single table which creates a link between a portal item its service URL and the feature class(s) and database it sits in. Trawling the forum has led me to look at using the service manifest as a source for this for which I've had some success however I've now encountered an issue where as I loop through each Service within a folder I hit an error if the service holds no manifest. This is because geoprocessing services (e.g. A custom data export / print service) holds no manifest and so the script fails.
I've tried a TRY function and also various way of trying to create a test case to filter our non MapServer services but with little success. This is mainly as each service in the returned list isn't string but a custom ArcGIS Server data type which is limited.
Does anyone have any ideas on how to filter services?
---------------------------------------------------------------------------------------------------------------------------------------
from arcgis.gis import *
import json
gis = GIS("portal", "username", "password",verify_cert=False,)
print("Successfully logged in as: " + gis.properties.user.username)
servers = gis.admin.serverss = servers.list() #list federated servers
server1 = s[1] #isolate portal server in list
services = server1.services.list(folder="Shared") #list the services within the folder "Shared"
for service in services: #list the manifest for each service URL
ii = service.iteminformation
manifest = ii.manifest
a = json.dumps(manifest)
b = json.loads(a)
fcnam = b['databases'][0]['datasets'] #scan the JSON and fine the list of feature classes
dbnam = b['databases'][0]['onServerName'] # scan the JSON and find the DB name
for x in fcnam:
print(service,dbnam,x['onServerName']) #print service with list of db fc names