Hello-
I have had success with this problem when modifying ESRI's open data script on github. The refresh function didn't update the date-updated shown on our Open Data site so I changed it a bit. I found that if I updated a property of a dataset (disclaimer, description, ... ) the 'Updated' date would update. Because the cache settings are set to Automatic users are getting fresh data. This script is run nightly from Task Scheduler.
Cache Settings:
Modified refresh function.
import requests
from arcgis.gis import GIS
def refresh(self):
"""
Refreshes all Open Data datasets and download cache. Will also update the index.
"""
gis = GIS("https://[yourAGOL].maps.arcgis.com",[yourUserString], [yourPasswordString])
DataStatus = {}
for dataset in self.OpenDataItems:
url = "https://opendata.arcgis.com/api/datasets/{0}/refresh.json?token={1}".format(dataset, self.token)
HTTPresponse = requests.put(url, verify=False)
if HTTPresponse.ok:
itemId = dataset[:-2]
item = gis.content.get(itemId)
itemName = item['title']
item.update({'description':" "})
logger.info("HTTP Response of: {0} for layer: {1}. Layer Updated".format(HTTPresponse.status_code , itemName))
DataStatus[itemName] = [HTTPresponse.status_code,itemId]
else:
logger.error("HTTP Response of: {0} for layer: {1}".format(HTTPresponse.status_code , dataset))
DataStatus[itemName] = [HTTPresponse.status_code,itemId]
synch_url = "https://opendata.arcgis.com/api/sites/{0}/groups/synchronize.json?token={1}".format(self.OpenDataSite, self.token)
requests.put(synch_url, verify=False)
return DataStatus
Environments:
Python 3.5.2
arcgis python api v 0.1 (from ArcGIS Pro's Python Package Manager)
Server 10.3.1
AGOL Open Data v1.9
[UPDATE]
I reference the ArcGIS API for Python from pypi under package name 'arcgis' but I'm not sure if it is updated anymore. You could/should reference from ArcGIS Pro's package manager. ArcGIS API for Python | ArcGIS for Developers