Skip to content

Instantly share code, notes, and snippets.

@HaydenElza
Created February 29, 2024 23:34
Show Gist options
  • Save HaydenElza/e5edbda817bb69618a308cdf60a9f7c0 to your computer and use it in GitHub Desktop.
Save HaydenElza/e5edbda817bb69618a308cdf60a9f7c0 to your computer and use it in GitHub Desktop.
Disable xss prevention for Esri feature service.

ArcGIS Online: Update Service to Allow HTML Links in Fields

By default feature layers hosted on ArcGIS Online do not allow you to insert links into fields because it could be "harmful". This code snippet allows you to edit the service definition of a feature layer to allow links to be added to fields.

# Allow html links in fields
from arcgis.features import FeatureLayerCollection
item = gis.content.get("c65363c5bfe54817b1985e69a8a3052f")
flc = FeatureLayerCollection.fromitem(item)
updated_properties = {"xssPreventionInfo": {
"xssPreventionEnabled": False
}}
flc.manager.update_definition(updated_properties)
flc.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment