I am trying to use the REST API from ArcGIS Online to refresh or overwrite a feature service.
I am using Python to upload an item using the addItem operation:
upload_url = (
f"{portal}/sharing/rest/content/users/{username}/{folder_id}/addItem"
)
params = {
"f": "json",
"token": token,
"type": "GeoPackage",
"title": title,
"tags": tags,
"description": description,
"overwrite": "true",
}
files = {"file": (filename, data)}
response = requests.post(upload_url, files=files, data=params)Afterwards, I can publish the item using the publish operation:
publish_url = f"{portal}/sharing/rest/content/users/{username}/publish"
publish_params = {
"f": "json",
"token": token,
"itemID": item_id,
"filetype": "geopackage",
"overwrite": "true",
"publishParameters": (
f'{{"name": "{name}", "layerInfo": {{"capabilities": "Query"}}}}'
),
}
# Publish the item
publish_response = requests.post(publish_url, data=publish_params)When I get new data, I want to update the data. I was able to do it for the item with the update operation:
update_url = (
f"{portal}/sharing/rest/content/users/{username}/items/{item_id}/update"
)
files = {"file": data}
params = {
"f": "json",
"token": token,
}
response = requests.post(update_url, files=files, data=params)However, the associated Feature Service is not updated with the new data, and I cannot figure out which method to use to refresh or overwrite it with the new data. Does anybody know how I can do it using the REST API?