Is there a way to find out with a script (in Python or JavaScript) which services a web-map is using and then find out which mxds were used to create these services? Which libraries or modules? I am so lost! I can do it by simply clicking and checking settings and properties, but need to do it for few maps and looking for an automated way.
This should be possible using Python. I'll include endpoints that you can use.
1) Get a list of each user in the Portal:
http://portal.domain.com/context/sharing/rest/portals/0123456789ABCDEF/users?excludeSystemUsers=true
2) Loop through each users content:
http://portal.domain.com/context/sharing/rest/content/users/<user>
3) Find each webmap in the content and loop through the services:
http://portal.domain.com/context/sharing/rest/content/items/<itemID>/data
4) If the host name of the URL matches whatever Server host you're expecting, parse the URL to construct the URL to the admin endpoint of the service:
https://server.domain.com/serve/rest/services/<serviceName>/MapServer -> https://server.domain.com:6443/arcgis/admin/services/<serviceName>.MapServer
5) Append iteminfo/manifest/manifest.json to get the information about datasets in the map:
6) Check the onPremisePath property for the original MXD path:
{ "databases": [{ "byReference": false, "onServerWorkspaceFactoryProgID": "esriDataSourcesGDB.FileGDBWorkspaceFactory.1", "onServerConnectionString": "DATABASE=C:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\<serviceName>.MapServer\\extracted\\v101\\default.gdb", "onPremiseConnectionString": "DATABASE=<path>", "onServerName": "default.gdb", "onPremisePath": "", "datasets": [{ "onServerName": "<dataSetName>" }] }], "resources": [{ "onPremisePath": "<path>", "clientName": "<machine>", "serverPath": "C:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\<serviceName>.MapServer\\extracted\\v101\\<serviceName>.msd" }] }