AnsweredAssumed Answered

Error when updating map while not logged in to ArcGIS Pro

Question asked by kclark_SubTelForum on Jan 6, 2020
Latest reply on Jan 7, 2020 by jborgion

I am receiving the following error when running a Python script to update a map for one of our Operations Dashboard:


C:\Users\kierc\projects\XXXXX XXXXXXX Extension Survey\Batch Files for Script Scheduling>"C:\ArcGIS_Pro\Conda\Cloned_Envs\arcgispro-py3-subtel\python.exe" "C:\Users\kierc\projects\api\"
Creating SD file
Traceback (most recent call last):
  File "C:\Users\kierc\projects\api\", line 33, in <module>, sddraft, sd_fs_name, 'MY_HOSTED_SERVICES', 'FEATURE_ACCESS', True, True)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 105, in CreateWebLayerSDDraft
    return _convertArcObjectToPythonObject(arcgisscripting._mapping.CreateWebLayerSDDraft(*_gp_fixargs([map_or_layers, out_sddraft, service_name, server_type, service_type, folder_name, overwrite_existing_service, copy_data_to_server, enable_editing, allow_exporting, enable_sync, summary, tags, description, credits, use_limitations], True)))


I have X'd out the actual name of the files as there is some potentially sensitive information associated with the names, but the character counts and spacing are preserved.


Additionally, this is only an issue if I am logged out in ArcGIS Pro. However, logging in to ArcGIS Pro is not a full solution as I will need to be updating maps soon for multiple organizations. The following is the Python script I am using:


import arcpy
import os, sys
from arcgis.gis import GIS

### Start setting variables
# Set the path to the project
prjPath = r'C:\Users\kierc\Documents\ArcGIS\Projects\XXXXXXXXXXXExt\XXXXXXXXXXXExt.aprx'

# Update the following variables to match:
# Feature service/SD name in, user/password of the owner account
sd_fs_name = "XXXXX_XXXXXX_Extention_Inshore_Survey_WFL1"
portal = "" # Can also reference a local portal
password = "XXXXXXXXXXXXX"

# Set sharing options
shrOrg = False
shrEveryone = False
shrGroups = ""

### End setting variables

# Local paths to create temporary content
relPath = r'C:\Users\kierc\projects\api\arcgistempcurrent'
sddraft = os.path.join(relPath, "CurrentUpdate.sddraft")
sd = os.path.join(relPath, "")

# Create a new SDDraft and stage to SD
print("Creating SD file")
arcpy.env.overwriteOutput = True
prj =
mp = prj.listMaps()[0], sddraft, sd_fs_name, 'MY_HOSTED_SERVICES', 'FEATURE_ACCESS', True, True)
arcpy.StageService_server(sddraft, sd)

print("Connecting to {}".format(portal))
gis = GIS(portal, user, password)

# Find the SD, update it, publish /w overwrite and set sharing and metadata
print("Search for original SD on portal…")
sdItem ="{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]
print("Found SD: {}, ID: {} n Uploading and overwriting…".format(sdItem.title,
print("Overwriting existing feature service…")
fs = sdItem.publish(overwrite=True)

if shrOrg or shrEveryone or shrGroups:
  print("Setting sharing options…")
  fs.share(org=shrOrg, everyone=shrEveryone, groups=shrGroups)

print("Finished updating: {} – ID: {}".format(fs.title,

Once again, specific filenames have been X'd out with number of characters and any spacing preserved. This script successfully updates the map as intended when logged in to ArcGIS Pro.