<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Overwrite or refresh hosted Feature Service with new data in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584837#M11156</link>
    <description>&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using the ArcGIS REST API (&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/users-groups-and-items/user-item-link/" target="_blank"&gt;https://developers.arcgis.com/rest/users-groups-and-items/user-item-link/&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;) instead of the Python package. I want to minimize dependencies in my environment because it keeps breaking.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Feb 2025 11:51:44 GMT</pubDate>
    <dc:creator>pzitman</dc:creator>
    <dc:date>2025-02-13T11:51:44Z</dc:date>
    <item>
      <title>Overwrite or refresh hosted Feature Service with new data</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584833#M11153</link>
      <description>&lt;P&gt;I am trying to use the REST API from ArcGIS Online to refresh or overwrite a feature service.&lt;/P&gt;&lt;P&gt;I am using Python to upload an item using the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;addItem&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;operation:&lt;/P&gt;&lt;PRE&gt;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)&lt;/PRE&gt;&lt;P&gt;Afterwards, I can publish the item using the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;publish&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;operation:&lt;/P&gt;&lt;PRE&gt;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)&lt;/PRE&gt;&lt;P&gt;When I get new data, I want to update the data. I was able to do it for the item with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;update&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;operation:&lt;/P&gt;&lt;PRE&gt;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)&lt;/PRE&gt;&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 11:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584833#M11153</guid>
      <dc:creator>pzitman</dc:creator>
      <dc:date>2025-02-13T11:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or refresh hosted Feature Service with new data</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584836#M11155</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/555275"&gt;@pzitman&lt;/a&gt;,&amp;nbsp;are you able to use the ArcGIS API for Python?&amp;nbsp; If so, here are some scripts you could use:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using/ta-p/1371248" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using/ta-p/1371248&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using/ta-p/904457" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using/ta-p/904457&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 11:45:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584836#M11155</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2025-02-13T11:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or refresh hosted Feature Service with new data</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584837#M11156</link>
      <description>&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using the ArcGIS REST API (&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/users-groups-and-items/user-item-link/" target="_blank"&gt;https://developers.arcgis.com/rest/users-groups-and-items/user-item-link/&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;) instead of the Python package. I want to minimize dependencies in my environment because it keeps breaking.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 11:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1584837#M11156</guid>
      <dc:creator>pzitman</dc:creator>
      <dc:date>2025-02-13T11:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or refresh hosted Feature Service with new data</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1587401#M11167</link>
      <description>&lt;P&gt;To work around the issue of overwriting or refreshing a feature service using the REST API, you can use the /deleteFeatures and /append methods. The /deleteFeatures method allows you to remove all current features, and the /append method lets you add features from your newly updated data. This approach effectively achieves the same result as overwriting or refreshing the service.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Delete Features:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/delete-features/" target="_blank" rel="nofollow noopener noreferrer"&gt;deleteFeatures&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Append Features:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/append-feature-service/" target="_blank" rel="nofollow noopener noreferrer"&gt;append&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;According to ESRI documentation, you cannot overwrite hosted feature services. For more details, see this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/developers-questions/overwriting-hosted-feature-service-via-rest/m-p/1584830#M7427" target="_blank" rel="nofollow noopener noreferrer"&gt;ESRI Community post&lt;/A&gt;. However, in the ArcGIS API for Python, the overwrite method appears to be an option. The code uses the REST API /publish method, which theoretically should not work, but it does. The exact mechanism behind this is unclear for me.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 10:29:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-or-refresh-hosted-feature-service-with/m-p/1587401#M11167</guid>
      <dc:creator>pzitman</dc:creator>
      <dc:date>2025-02-20T10:29:00Z</dc:date>
    </item>
  </channel>
</rss>

