Select to view content in your preferred language

Using ArcPY to Overwrite AGOL Feature Service, ArcGIS Pro Symbology not being Applied

2 weeks ago
Labels (1)
New Contributor III

I have a python script that overwrites a feature service on a nightly basis.  Up until this weekend the script was running great.  Now when my script runs, it does finish without any errors or warnings but the symbology in my ArcGIS Pro project is not being applied.

The symbology that I use in ArcGIS Pro...


My feature service symbology, in AGOL, before my python script is run...


My feature service symbology after I run my script...


And when I manually overwrite the service in ArcGIS Pro, the symbology is then applied properly again.

I'm not sure what has changed that my python script no longer applies the appropriate symbology.


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

prjPath = r"C:\GIS_Workspace\Projects\Berry_Disease_Mapping\Berry_Disease_Modelling\Berry_Risk_Prediction.aprx"

print("Berry_Disease_Risk_Ratings Service Creation")
sd_fs_name = "Berry_Disease_Risk_Modelling"
item_id = "ae23b9349c9942a0b34cb919be434919"
portal = "" 
user = "LOGIN"
password = "XXXXXXX"

# Local paths to create temporary content
sddraft = r"C:\GIS_Workspace\Projects\Berry_Disease_Mapping\Berry_Disease_Risk_Modelling.sddraft"
sd = r"C:\GIS_Workspace\Projects\Berry_Disease_Mapping\" 

# Create a new SDDraft and stage to SD
print("Creating SD file")
arcpy.env.overwriteOutput = True
prj =
mp = prj.listMaps('For_Mapping_Service')[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 = gis.content.get(item_id)
print("Found SD: {}, ID: {} n Uploading and overwriting…".format(sdItem.title,
print("Overwriting existing feature service…")
fs = sdItem.publish(overwrite=True)

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


I should note that I recently upgraded my Pro to 3.3 earlier and ever since then my script has not been behaving the way that it use to.  Not sure if one has anything to do with the other.

I also have another thread that outlines how item.share has been deprecated as well.  Also started after my upgrade.

Overwrite ArcGIS Online Feature Service using ArcG... - Esri Community

0 Kudos
1 Reply
MVP Esteemed Contributor

I don't have any answer for why arcpy is dropping your symbology settings, but I'd encourage you to move your process to a truncate/append method rather than simply overwriting. This would refresh the data, but would not touch any layer configuration or symbology settings.

- Josh Carlson
Kendall County GIS