Select to view content in your preferred language

Update sourceUrl for a feature service?

305
3
06-25-2024 01:26 PM
ElisabethFenn
New Contributor III

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.

0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @ElisabethFenn,

You can do this easily with the AGOL Assistant.  

JakeSkinner_0-1719486114646.png

 

0 Kudos
EarlMedina
Esri Regular Contributor

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.

0 Kudos
ElisabethFenn
New Contributor III

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: 

Screenshot 2024-07-09 090912.png

 

 

 

0 Kudos