I am writing a Python script to automate publishing Map Services for use in ArcGIS Online. My workflow follows the sample code in Example 1 from this ArcGIS Help page on the CreateMapSDDraft tool: Create a Service Definition Draft (.sddraft) file with CreateMapSDDraft, stage the service definition with StageService, then UploadServiceDefinition.

However, there are parameters available in the "point-and-click" process of publishing a service in ArcMap that I'm unable to add with the syntax of the CreateMapSDDraft tool. In the Item Description window of the ArcMap Service Editor, I want to add a Summary, list of Tags, Description, Access Constraints, and Credits before publishing a service. Screenshot of Service Editor window The CreateMapSDDraft arcpy syntax only allows me to add a Summary and Tags to my item. i.e., CreateMapSDDraft (map_document, out_sddraft, service_name, {server_type}, {connection_file_path}, {copy_data_to_server}, {folder_name}, {summary}, {tags}). I cannot find a place within the help files of the other geoprocessing tools used in my script to add/alter the Description, Access Constraints, or Credits of my service.

What can I add to my script to allow me to define these attributes in the service that is ultimately uploaded?


Option 1: Edit SDdraft file directly

You will need to create the SDdraft files and then modify them using the minidom library before you publish. There is an example of this in the 10.3 help. See 'Modify SDDraft example 1': http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/createmapsddraft.htm

From ESRI's example, a service's description is changed to 'US Counties Map':

import arcpy
import xml.dom.minidom as DOM 
# the new description
newDesc = 'US Counties Map'
xml = r"C:\Project\Counties.sddraft"
doc = DOM.parse(xml)
# find the Item Information Description element 
descriptions = doc.getElementsByTagName('Description')
for desc in descriptions:
if desc.parentNode.tagName == 'ItemInfo':
    # modify the Description
    if desc.hasChildNodes():
        desc.firstChild.data = newDesc
        txt = doc.createTextNode(newDesc)
# output to a new sddraft
outXml = r"C:\Project\Output\CountiesForWeb.sddraft"
f = open(outXml, 'w')
doc.writexml( f )

Option 2: Use Python API and JSON

ESRI's python API was recently updated to support service modification. You can use the edit function to modify the service by submitting a JSON representation of the service. You can use Python's JSON library to add a description.

JSON Example. See Description tag:

"currentVersion": <currentVersion>, //Added at 10.0 SP1
"serviceDescription" : "<serviceDescription>",
"mapName" : "<mapName>"
"description": "<description>",
"copyrightText" : "<copyrightText>",
"supportsDynamicLayers" : <true|false>, //Added at 10.1
"layers": [ //the spatial layers published by this service

API DOC: http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.server.html?highlight=sd#arcgis.gis.server.Service

JSON DOC: http://gisappserv4.spokanecounty.org:6080/arcgis/sdk/rest/index.html#/Map_Service/02ss0000006v000000/

  • Thank you! Re: the 1st suggestion, this solves the problem of adding a Description, but is there documentation someplace where I could see a list of what tag names exist and are possible to edit with this method? (In order to identify and edit the correct element for Use Constraints and Credits.) – neirbom9 Jan 9 '18 at 0:02
  • I'm not sure. I'd personally go for option 2. – psl Jan 9 '18 at 0:14

Not sure if this still an issue for you but I was having the same problem and finally found the tag name "AccessInformation". I'm using 10.6.1 and the tag name does not have proper formatting(probably an ESRI BUG) but if you modify this in the sddraft manually and then stage a service it works. I just have to figure out how to create the tag in my script now.

  • FYI: ESRI has logged this as a bug: BUG-000123177 – Sam Jun 26 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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