Find a layer's data source

1124
3
11-02-2021 07:03 PM
AnthonyRyanEQL
Regular Contributor

Hi all,

I'm struggling to find information showing the relationship/dependency of data source to a layer within a service. Is it possible to call 1, 2 or whatever it takes REST API calls to find what data source (eg. enterprise geodatabase and featureclass) a layer within a service is using?

I know how to get the service's manifest.json which tells me about the enterprise geodatabase, RDBMS, username, etc and what feature classes it references as a collective.

Thanks

0 Kudos
3 Replies
GaetanPRU
New Contributor III

Hello,

You can read the mxd or mapx file in the service's directory with arcpy in Python too. You will find database / file source and the layer's ID with which you can make the connection between database and service.

You can find the path to the mxd file in the service properties. Do a loop on all services to have all files of all services.

Managing GIS Servers with Python 

Work with arcpy and ArcGIS Project 

# Create temporary ArcGIS Projec to import service file
aprx = arcpy.mp.ArcGISProject(r"C:\projectArcGISPRO.aprx")
# Import service file with file path in service's properties
aprx.importDocument(filepath)
#List all maps in ArcGIS PRO
mapList = aprx.listMaps()
    for m in mapList:
        #List layers in map
        layerList = m.listLayers()
        for l in layerList:
            if not l.isGroupLayer:
                if l.supports("DATASOURCE"):
                    #Find datasource 
                    datasource = l.dataSource
                    #Find layerID used in service
                    layerID = l.getDefinition('V2').serviceLayerID

 

 

GaetanPRU
0 Kudos
AnthonyRyanEQL
Regular Contributor

Thanks for the reply. I have used Python before to get this information but as our environment is cloud based and controlled by a 3rd party company, I don't have access to the original project files and therefore I'm looking for a REST API only solution.

0 Kudos
YohanBienvenue
Occasional Contributor II

Did you ever find a way to do this using the REST API?

The manifest.json of the service gives me all the source names, but it doesn't tell me which layer uses which source.

I'd rather not use python since I'd have to install a web server on each and every one of our ArcGIS Server instances (unless there's a way to call a python script directly from the REST API).

0 Kudos