Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What arcpy module can I use to write a python script to mine for fields of my map service properties and export them to a .tx file? I assume we need to tap into GIS Servers within the ArcCatalog interface?

share|improve this question
What kind of properties are you interested in? Layer names? Supported service interfaces? Data paths? – om_henners Nov 29 '12 at 23:27
What version of ArcGIS Server are you on? (edit Q) – Simon Dec 1 '12 at 12:11
Server 10. Trying to access service properties whose fields include service type, service capabilities and parameters, document path, and caching information. You can only get these fields from ArcCatalog>GIS Services>Service Properties dialog box and not from a REST URL. – pdog Dec 2 '12 at 22:27

Quick and dirty code... substitute the "print" for some code to write to a textfile if thats what you want. You'll notice its hardcoded to one specific layer in a map service. You can enhance to loop through all layers, or even loop through all services on a server THEN all layers, THEN get fields.

import urllib, urllib2, json

def getServiceFields(URL): 

    fURL = URL + "?f=json"

    openURL = urllib2.urlopen(fURL, '').read()    
    outJson = json.loads(openURL)   

    return outJson["fields"]   

if __name__ == "__main__": 

    URL = r""

    fields = getServiceFields(URL)

    for f in fields:
        print "Name : {}, Type : {}".format(f["name"], f["type"])

Also for reference, heres what you can get out of "f":






(per a 10.1 server, may change for 10.0)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.