For referenced feature layers brought into AGO from our enterprise server I can access the sourceUrl using item.sourceUrl. Is it possible to also update the sourceUrl?
I'd like to point the referenced feature layer at a different REST URL to update the underlying data without creating a new item and losing popup configuration, etc.
I've not tested this, but assuming the schema is exactly the same then you should be able to do this for your specific case (i.e., you added Enterprise Feature Services as items to your AGOL content).
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "user", "passwd")
new_url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/RedlandsEmergencyVehicles/FeatureServer"
your_item_id = "4567fd6780e74ccb877fasdfghjlkl"
item = gis.content.get(your_item_id) # here the item id of the Feature Service you added to AGOL
item_properties = {"url": new_url}
item.update(item_properties=item_properties)
Coding this may not be worthwhile for a few urls. As Jake mentioned, you can do the same thing rather quickly in AGO Assistant.
Thanks for the ideas @JakeSkinner and @EarlMedina!
I've tried both these methods and haven't been able to get either to work. My first thought had also been to use AGO assistant, but I'm trying to change the source URL for an item, not in a layer in a web map. When I go to the item details in AGO assistant, I can edit the JSON and change the source URL but the changes don't actually stick when I save them.
The code suggested here throws an error I've run into before trying to figure this out:
Just want to confirm I've encountered the same issue. I've tried using ArcGIS Online itself, AGO Assistant, Geo Jobe and the ArcGIS API for Python. All methods appear to save the changes, but the changes don't persist and the source URL remains the same.
There appears to be no way to update the source URL for in a referenced feature layer.