Hi @RehanChaudhary
Manually apply the symbology and then export the JSON. Print the JSON to screen using the snippet below.
from arcgis import GIS
import json
agol = GIS("home")
item = agol.content.get("***item_id***")
lyr = item.layers[0]
print(json.dumps(lyr.properties["drawingInfo"], indent=4))
Open a Notepad and add the below first, then copy and past the JSON output into the placeholder. Save the file with a .json file extension.
{
"drawingInfo" :
*** copy and paste JSON here***
}
This .json file is now your symbology template for the layer. You can apply the symbology using the code below every time you update. You can alter your current script and add similar code to update the symbology after the update.
from arcgis import GIS
import json
agol = GIS("home")
item = agol.content.get("***item_id***")
lyr = item.layers[0]
## open the JSON file
with open(r"C:\path\to\symbology.json") as json_data:
data = json.load(json_data)
lyr.manager.update_definition(data)
~ learn.finaldraftmapping.com