Rebuild Scene Layer Cache with Python API

04-11-2020 09:59 PM
Status: Open
Occasional Contributor

It would be helpful to expose the "Manage Cache" functionality for a Scene Layer - 3D Object with the ArcGIS Python API so that updating the scene layer cache to reflect any changes made in the feature layer used to publish the scene layer can be done programmatically.

I have a workflow where many edits are made to attributes that control symbology on the feature layer used to publish the scene layer.  The new symbology needs to be reflected in the web scene. It would be preferably to do this on some set interval, likely several times a day with a scheduled task or after some volume of edits via web hook rather than rely on a user to remember to do it manually.

Also see, 


Update:  Although this hasn't been exposed in the ArcGIS Python API (to my knowledge), we where able to script this using Python and the ArcGIS Rest API.


Hi @JustinReynolds 

Can you share more on the REST API commands for this?


Hi @JustinReynolds , thanks for your feedback. In my situation, I also confirm that via the web interface of the rest api (.../arcgis/rest/services/System/SceneCachingControllers/GPServer/Manage%20Scene%20Cache/submitJob) everything works well. However, when I try to submit this job via an external app (Integromat for example), the job is nicely created and lauched but quite quickly it fails, indicating an error (esriJobMessageTypeError: ERROR 001812: Unable to connect to the database used for scene caches (In-server connection failed. Server is federated but server environment doesn't have token or referer.)".
Can you please provide the way you triggered it via the rest api ? On my side, I used a POST method, with url-encoded fields :

Also, when you say that you submit the job via python, did you launch your python script directly from the arcgis server machine (assuming that you're on a arcgis entreprise deployment) ?

Have a good one,



Pierre here are some of the key inputs in the request to rebuild the cache, hope this helps...


_referer_url = "https://{}".format(host)

submit_url = "https://{}/server/rest/services/System/SceneCachingControllers/GPServer/Manage%20Scene%20Cache/submitJob?.format(host)

service_url = '{}/server/rest/services/Hosted/{}/SceneServer'.format(_referer_url,                                                                   service_name)

params = {'service_url': service_url, 'num_of_caching_service_instances': 2, 'layer': {}, 'update_mode': 'RECREATE_ALL_NODES', 'update_extent': 'DEFAULT',
'area_of_interest': {"displayFieldName": "", "geometryType": "esriGeometryPolygon", "spatialReference": {"wkid": 54051, "latestWkid": 54051}, "fields": [{"name": "OID", "type": "esriFieldTypeOID", "alias": "OID"}, {"name": "updateGeom_Length", "type": "esriFieldTypeDouble","alias": "updateGeom_Length"}, {"name": "updateGeom_Area", "type": "esriFieldTypeDouble", "alias": "updateGeom_Area"}], "features": [], "exceededTransferLimit": False}, 'f': 'json', 'token': self.token}
headers = {"Referer": self._referer_url} 

request = urllib.request.Request(submit_url, data=self._encode_data(params), headers=headers)

with contextlib.closing(urllib.request.urlopen(request)) as response:
    content =
    content_decoded = content.decode("utf-8")
    result = json.loads(content_decoded)





@PierreMarcombe  @vipapril See the comment from Dallas above.


Thank you all!