Accessing Service Properties via ArcGIS Rest URL

03-12-2020 10:28 AM
New Contributor II

I am trying to obtain the name of a service while iterating through a web map.  As I itterate through the web map, I run into instances where the entire service has been added.  Therefore, I itterate through the the layer['layers'] to obtain the attributes for the "sub services.  However, I'm running into cases where the "sub services" do not have all the properites in which I'm looking for. 

Therefore,  am trying to access the service properties directly from the server utilizing the arcgis.gis.server module.  It is quite easy to construct a URL, however, I am having trouble accessing the properties.  I have yet to find a "get" function, that simply allows me to plug in the ArcGIS Rest URL; rather than having to enter all of the server information .  

I guess my question is, Is there a "get" function that will allow me to return all the properties of a service including name, capabilites, etc?

Managing your GIS servers | ArcGIS for Developers 

import arcgis.gis
from arcgis.mapping import WebMap
from arcgis.gis.server import Server
import os
gis=arcgis.gis.GIS(hportal URL,"UN","PW")
user = gis.users.get('UN)
print ("Logged Into Portal")
#Web map 
print ("Defyning Web Map")
#webmapid = input("Enter Map ID: ")
webmapid = "#####"
usermapid = gis.content.get(str(webmapid))
wm = WebMap(usermapid)
for layer in wm.layers:
    print (layer['title'])

    if layer['layerType'== 'ArcGISMapServiceLayer' and layer['url'].endswith("MapServer"😞
        for i in range(len(layer['layers'])):
            arcgis.gis.server.Service(layer['url'],'Map Service') #does not work
            print (layer['title'+ " /// " + layer['layers']['name']) #instance where I want to return the name 
0 Kudos
0 Replies