Setting the refresh interval for a hosted feature layer

712
2
01-16-2020 12:49 PM
TraceStanford1
New Contributor III

I have a project that will be adding hosted feature layers to a map, and eventually removing them and archiving the data for the layer. I would like to be able to set the refresh interval for the layer with the Python API so that the web map has a near live view of the data. I can set it manually in AGOL, but it will be a pain to have to manually do this for each layer. Does anyone know if it's possible to set the refresh interval using the Python API?

0 Kudos
2 Replies
AnttiKajanus3
New Contributor III

You can do it like this.

from arcgis.gis import GIS
import getpass

password = getpass.getpass("Enter password: ")

gis = GIS('org', 'username', password)
print("Connected to: {}\nConnected as: {}".format(
                                                 gis.properties.urlKey + "." + gis.properties.customBaseUrl,
                                                 gis.users.me.username))


webmap_item = gis.content.get('ce80541f342546319d99308cbeb9f675')
webmap_item

from arcgis.mapping import WebMap
webmap = WebMap(webmap_item)
webmap

json_key = 'refreshInterval'
for layer in webmap.layers:
    print(layer.title)
    if json_key in layer:
        print('refreshInterval already exits with value {}'.format(layer[json_key]))
    else:
        print('Adding refreshInterval to the layer with value 2')
        layer[json_key] = 2    

webmap.update()
AsadAliBaig
New Contributor II

webmap_item refers to item of type web map. I'm trying to set refresh interval on my published tile layer. Any idea how can I do that for an individual layer rather than a map

0 Kudos