0

I am getting error while creating the MapSDDraft using Python.

import arcpy
import os
import xml.dom.minidom as DOM
workspace = r'C:\\Users\\xyz\\Documents\\ArcGIS\\'
mxd = 'TEST.mxd'
con = r'C:\\Users\\xyz\\AppData\\Roaming\\ESRI\\Desktop10.6\\ArcCatalog\\arcgis on domain(xyz.in)(admin)'
service = 'FirstService'
summary = 'testing purpose'
tags = 'test'
mapDoc = arcpy.mapping.MapDocument(workspace + mxd)
sddraft = workspace + service + '.sddraft'
sd = workspace + service + '.sd'
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc,sddraft,service,"ARCGIS_SERVER",con,True,None,summary,tags)

Runtime error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\utils.py", line 182, in fn_
    return fn(*args, **kw)
  File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\mapping.py", line 398, in CreateMapSDDraft
    return convertArcObjectToPythonObject(arcgisscripting._createMapSDDraft(*gp_fixargs([map_document, out_sddraft, service_name, server_type, connection_file_path, copy_data_to_server, folder_name, summary, tags], True, False)))
ValueError: C:\\Users\\xyz\\AppData\\Roaming\\ESRI\\Desktop10.6\\ArcCatalog\\arcgis on domain(xyz.in)(admin)

Actually, I have the ArcGIS Server on another machine and the ArcMap on another machine. I am writing script where ArcMap is installed. I am totally new to ArcPy.

1

r'C:\\Users\\xyz\\AppData\\Roaming\\ESRI\\Desktop10.6\\ArcCatalog\\arcgis on domain(xyz.in)(admin)' is incorrect. When using a raw string you don't use double backslashes.

Try:

con = r'C:\Users\xyz\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\arcgis on domain(xyz.in)(admin)'

Also:

workspace = r'C:\Users\xyz\Documents\ArcGIS'

Finally:

mapDoc = arcpy.mapping.MapDocument(workspace + "\\" + mxd)

  • 2
    Or better, mapDoc = arcpy.mapping.MapDocument(os.path.join(workspace,mxd)) – Vince Jun 25 at 22:45
  • Thanks. I got my error. I have mentioned "ARCGIS_SERVER" in parameters and passing the connection file path. I changed "ARCGIS_SERVER" to "CONNECTION_FROM_FILE" and it works. – Mayur Patel Jun 26 at 8:49
  • Hi @Vince, I am getting error in arcpy.UploadServiceDefinition_server(sd, "C:\Users\xyz\AppData\Roaming\ESRI\Desktop10.6\arcgis\xyz.domain.com(admin).ags" Error message:"Unable to create service: ERROR: code:403, Service name is invalid. The name contains illegal character ':'. Access to this resource is forbidden, regardless of authorization". Any idea? – Mayur Patel Jun 30 at 7:48
  • @MayurPatel Please transfer your comments on the answer to the body of the question where they will be legible. It also seems like you need to add more code, and probably a print or AddMessage of the input to the failing command. Services should only have alphanumeric characters (plus underscore). – Vince Jun 30 at 12:50

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.