Programmatically update hosted feature layer in AGOL

776
2
10-10-2019 09:48 AM
Highlighted
New Contributor

I am wondering what are the options for updating a hosted feature layer in AGOL. For context, I will be hosting point layer with about 500 features that will be updated nightly from a scheduled task. The initial publishing of the layer does not need to be programmatic, but the nightly update does.

I have been looking into using the REST API update/delete/create endpoints for doing these nightly updates.

My question is, are there any other options for performing these updates outside the REST API? I see there is also a Python API and Native SDKs. Are those libraries using the REST API under the hood?

Thanks.

Tags (1)
Reply
0 Kudos
2 Replies
Highlighted
Esri Regular Contributor

Hi Joe Saltenberger

The ArcGIS API for Python does use the REST API under the hood. This blog goes into that in a little more depth: ArcGIS API for Python Core Concepts Part 1: Python, APIs, and REST 

There are some good resources on using the Python API to accomplish the workflow here: 

Updating features in a feature layer | ArcGIS for Developers 

https://community.esri.com/thread/198763-update-feature-service-with-arcgis-api-for-python 

Hope this helps,

-Peter

Reply
0 Kudos
Highlighted
MVP Regular Contributor

The following code works for me in order to update hosted feature layer (i.e., overwrite the data):

from arcgis.gis import GIS
source = GIS("http://yourorganization.maps.arcgis.com", "username", "password", verify_cert=False)
csv = source.content.get('a4e4587122354eb2847d461263e3ccb7')
csv.update({}, r'C:\TEMP\data.csv')
csv.publish(overwrite=True)‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos