I want to update over 100 MXDs by adding 4/5 ArcGIS Online/ArcGIS REST Services directory layers. I am unsure whether this is possible using Python and can only find documentation on how to access ArcGIS Online layers via the ArcGIS API and Jupyter Notebooks. How can I add data from ArcGIS Online via Python to a MXD or even how to use ArcGIS Online layers within ArcPy?
Sample code I've tried so far:
from arcgis.gis import GIS trailheads_id = '7ff2ea905ad343f98dfd09a723938784' gis = GIS() trailheads_item = gis.content.get(trailheads_id) trailheads_item import arcpy # Hook into the map document mxd = arcpy.mapping.MapDocument(r"Path\To\MapDocument") # Hook into the data frame where you want to add the layer df = arcpy.mapping.ListDataFrames(mxd)