Publish the map service to hosted server.

342
1
09-18-2018 08:39 AM
ManjariGoyal
New Contributor III

I am trying to overwrite the existing service but I am getting the error below. The python version I am using is 3.5 and ArcGIS PRO version is 2.0. I am also attaching the Python script I am using.

Traceback (most recent call last):
File "\\i-file\Sprint\Network\02\NGN\RingConstruction\AlteryxScripts\publishtest.py", line 56, in <module>
arcpy.UploadServiceDefinition_server(r"\\i-file\Sprint\Network\02\NGN\RingConstruction\DarkFiberProgressReport\NNI\NNItest.sd", "My Hosted Services", "NNItest", "EXISTING","NNI", "STARTED")
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 876, in UploadServiceDefinition
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 873, in UploadServiceDefinition
retval = convertArcObjectToPythonObject(gp.UploadServiceDefinition_server(*gp_fixargs((in_sd_file, in_server, in_service_name, in_cluster, in_folder_type, in_folder, in_startupType, in_override, in_my_contents, in_public, in_organization, in_groups), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 001398: Service name 'NNItest' already exists.
Failed to execute (UploadServiceDefinition).

Any help is appreciated.

0 Kudos
1 Reply
MarisaClaggett
Occasional Contributor II

Hi Manjari,

It looks like your script is attempting to publish a new service rather than overwrite a service.  You should take a look at code sample example 3 in the following documentation, which provides syntax needed to overwrite a service.

Stage Service—Help | ArcGIS Desktop 

Have you also thought about using the ArcGIS API for Python? Using the arcgis python module installed with Pro, you can utilize a much simpler workflow and script.

overwriting_feature_layers | ArcGIS for Developers 

Hope this helps!

Best,

Marisa

0 Kudos